Skip to content

Commit

Permalink
Fixes several migration issues: 1) slideshows were not being migrated…
Browse files Browse the repository at this point in the history
…, 2) is_existing modules were sometimes taking the place of the is_original module which prevented editing (e.g., you had to remain aggregated to an invisible module) 3) a permission code warning was injected with recent permission name update 4) fixes formatting of expFiles list [#523 state:resolved]
  • Loading branch information
dleffler committed Feb 2, 2012
1 parent c8d4a43 commit 218e248
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 74 deletions.
4 changes: 2 additions & 2 deletions framework/modules-1/navigationmodule/class.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static function levelTemplate($parent, $depth = 0, $parents = array()) {

// Need to check and see if the internal_id is pointing at an external link.
$dest = $db->selectObject('section','id='.$child->internal_id);
if ($dest->alias_type == 1) {
if (!empty($dest->alias_type) && $dest->alias_type == 1) {
// This internal alias is pointing at an external alias.
// Use the external_link of the destination section for the link
$child->link = $dest->external_link;
Expand All @@ -353,7 +353,7 @@ static function levelTemplate($parent, $depth = 0, $parents = array()) {
// (see datatypes/section.php)

//added by Tyler to pull the descriptions through for the children view
$child->description = $dest->description;
$child->description = !empty($dest->description) ? $dest->description : '';

$child->link = expCore::makeLink(array('section'=>$child->internal_id));
}
Expand Down
131 changes: 65 additions & 66 deletions framework/modules/migration/controllers/migrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,19 @@ public function migrate_content() {
$newmodule['views'] = $module->view;
$newmodule['title'] = $module->title;
$newmodule['actions'] = '';
$_POST['current_section'] = 1;
// $_POST['current_section'] = 1; //FIXME we need to find the real page instead of just assigning Home
$section = $old_db->selectObject('sectionref',"module='".$iloc->mod."' AND source='".$iloc->src."' AND is_original='0'");
$_POST['current_section'] = empty($section->section) ? 1 : $section->section;
$module = container::update($newmodule,$module,expUnserialize($module->external));
$config = $old_db->selectObject('calendarmodule_config', "location_data='".serialize($iloc)."'");
$config->id = '';
$config->enable_categories = 1;
$config->enable_tags = 0;
$config->location_data = $module->internal;
$config->aggregate = serialize(Array($iloc->src));
$db->insertObject($config, 'calendarmodule_config');
if ($iloc->mod == 'calendarmodule') {
$config = $old_db->selectObject('calendarmodule_config', "location_data='".serialize($iloc)."'");
$config->id = '';
$config->enable_categories = 1;
$config->enable_tags = 0;
$config->location_data = $module->internal;
$config->aggregate = serialize(Array($iloc->src));
$db->insertObject($config, 'calendarmodule_config');
}
}
$res = $db->insertObject($module, 'container');
if ($res) { @$this->msg['container']++; }
Expand All @@ -561,11 +565,11 @@ public function migrate_content() {
$loc->mod = $item->module;
$loc->src = $item->source;
$loc->int = '';
// if (array_key_exists($item->module, $this->new_modules)) {
if (array_key_exists($item->module, $this->new_modules)) {
$loc->mod = $this->new_modules[$item->module];
$item->module = $this->new_modules[$item->module];
$item = $this->convert_permission($item);
// }
$item = $this->convert_permission($item);
}
if ($item && $db->selectObject('container',"internal = '".serialize($loc)."'")) {
$db->insertObject($item,'userpermission');
if ($item->permission == 'edit') { // if they had edit permission, we'll also give them create permission
Expand All @@ -583,11 +587,11 @@ public function migrate_content() {
$loc->mod = $item->module;
$loc->src = $item->source;
$loc->int = '';
// if (array_key_exists($item->module, $this->new_modules)) {
if (array_key_exists($item->module, $this->new_modules)) {
$loc->mod = $this->new_modules[$item->module];
$item->module = $this->new_modules[$item->module];
$item = $this->convert_permission($item);
// }
}
if ($item && $db->selectObject('container',"internal = '".serialize($loc)."'")) {
$db->insertObject($item,'grouppermission');
if ($item->permission == 'edit') { // if they had edit permission, we'll also give them create permission
Expand Down Expand Up @@ -770,7 +774,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'textmodule';
$linked = true;
break;
Expand Down Expand Up @@ -799,7 +803,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'rotatormodule';
$linked = true;
break;
Expand Down Expand Up @@ -827,7 +831,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'snippetmodule';
$linked = true;
break;
Expand Down Expand Up @@ -866,7 +870,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'linklistmodule';
$linked = true;
break;
Expand Down Expand Up @@ -907,7 +911,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'linkmodule';
$linked = true;
break;
Expand Down Expand Up @@ -962,7 +966,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'swfmodule';
$linked = true;
break;
Expand Down Expand Up @@ -1017,7 +1021,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'newsmodule';
$linked = true;
break;
Expand Down Expand Up @@ -1097,7 +1101,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects('filedownloads', "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'resourcesmodule';
$linked = true;
break;
Expand Down Expand Up @@ -1173,7 +1177,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects('photo', "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'imagegallerymodule';
$linked = true;
break;
Expand Down Expand Up @@ -1214,41 +1218,33 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects('photo', "location_data='".serialize($ploc)."'") || $module->is_existing) {
$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();
}
}
}
}
}
$gis = $old_db->selectArrays('slideshow_slide', "location_data='".serialize($iloc)."'");
foreach ($gis as $gi) {
$photo = new photo();
$loc = $iloc;
$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,'');
}
}
}
break;
case 'headlinemodule':

Expand All @@ -1257,7 +1253,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'headlinemodule';
$linked = true;
break;
Expand Down Expand Up @@ -1304,7 +1300,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'weblogmodule';
$linked = true;
break;
Expand Down Expand Up @@ -1393,7 +1389,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects('faqs', "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'faqmodule';
$linked = true;
break;
Expand Down Expand Up @@ -1427,7 +1423,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'listingmodule';
$linked = true;
break;
Expand Down Expand Up @@ -1476,7 +1472,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects('formbuilder_form', "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'contactmodule';
$linked = true;
break;
Expand Down Expand Up @@ -1556,7 +1552,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects('youtube', "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'youtubemodule';
$linked = true;
break;
Expand Down Expand Up @@ -1592,7 +1588,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects('flowplayer', "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'mediaplayermodule';
$linked = true;
break;
Expand Down Expand Up @@ -1636,7 +1632,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
if ($db->countObjects('banner', "location_data='".serialize($ploc)."'") || $module->is_existing) {
$iloc->mod = 'bannermodule';
$linked = true;
break;
Expand Down Expand Up @@ -1687,7 +1683,7 @@ private function convert($iloc, $module, $hc=0) {
//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)."'")) {
// if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'") || $module->is_existing) {
// $iloc->mod = 'addressbookmodule';
// $linked = true;
// break;
Expand All @@ -1709,8 +1705,8 @@ private function convert($iloc, $module, $hc=0) {
$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->state = empty($state->id) ? 0 : $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'] : 'address@website.com';
$addr->organization = $address['business'];
Expand Down Expand Up @@ -1777,7 +1773,7 @@ private function pulldata($iloc, $module) {

switch ($iloc->mod) {
case 'calendarmodule':
if ($db->countObjects('calendar', "location_data='".serialize($iloc)."'")) {
if ($db->countObjects('calendar', "location_data='".serialize($iloc)."'") || $module->is_existing) {
$linked = true;
break;
}
Expand Down Expand Up @@ -1806,7 +1802,7 @@ private function pulldata($iloc, $module) {
@$this->msg['migrated'][$iloc->mod]['name'] = $iloc->mod;
break;
case 'simplepollmodule':
if ($db->countObjects('poll_question', "location_data='".serialize($iloc)."'")) {
if ($db->countObjects('poll_question', "location_data='".serialize($iloc)."'") || $module->is_existing) {
break;
}
$questions = $old_db->selectObjects('poll_question', "location_data='".serialize($iloc)."'");
Expand All @@ -1829,7 +1825,7 @@ private function pulldata($iloc, $module) {
@$this->msg['migrated'][$iloc->mod]['name'] = $iloc->mod;
break;
case 'formmodule':
if ($db->countObjects('formbuilder_form', "location_data='".serialize($iloc)."'")) {
if ($db->countObjects('formbuilder_form', "location_data='".serialize($iloc)."'") || $module->is_existing) {
break;
}
$form = $old_db->selectObject('formbuilder_form', "location_data='".serialize($iloc)."'");
Expand Down Expand Up @@ -1881,6 +1877,9 @@ private function pulldata($iloc, $module) {
*/
private function add_container($iloc,$m,$linked=false) {
global $db;

$old_db = $this->connect();
$section = $old_db->selectObject('sectionref',"module='".$iloc->mod."' AND source='".$iloc->src."' AND is_original='0'");
if ($iloc->mod != 'contactmodule') {
$iloc->mod = $this->new_modules[$iloc->mod];
$m->internal = (isset($m->internal) && strstr($m->internal,"Controller")) ? $m->internal : serialize($iloc);
Expand All @@ -1903,7 +1902,7 @@ private function add_container($iloc,$m,$linked=false) {
$newmodule['views'] = $m->view;
$newmodule['title'] = $m->title;
$newmodule['actions'] = $m->action;
$_POST['current_section'] = 1;
$_POST['current_section'] = empty($section->section) ? 1 : $section->section;
$m = container::update($newmodule,$m,expUnserialize($m->external));
$newmodinternal = expUnserialize($m->internal);
$newmod = explode("Controller",$newmodinternal->mod);
Expand Down
12 changes: 6 additions & 6 deletions framework/modules/migration/views/migration/migrate_files.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@
<table class="exp-skin-table">
<thead>
<tr>
<th width=5%>&nbsp;</th>
<th width=30%>{"File Name"|gettext}</th>
<th width=65%>{"Directory"|gettext}</th>
<th width="5%">&nbsp;</th>
<th width="30%">{"File Name"|gettext}</th>
<th width="65%">{"Directory"|gettext}</th>
</tr>
</thead>
<tbody>
{foreach from=$files item=file name=files}
<tr class="{cycle values="even,odd"}">
<td width=5%>{if $file->exists}{img src=$smarty.const.ICON_RELATIVE|cat:'clean.png'}{else}<span style="color:red"><b>??</b></span>{/if}</td>
<td width=30%>{$file->filename}</td>
<td width=65%>{$file->directory}</td>
<td width="5%">{if $file->exists}{img src=$smarty.const.ICON_RELATIVE|cat:'clean.png'}{else}<span style="color:red"><b>??</b></span>{/if}</td>
<td width="30%">{$file->filename}</td>
<td width="65%">{$file->directory}</td>
</tr>
{foreachelse}
<tr><td colspan=3>{'No files found in the database'|gettext} {$config.database}</td></tr>
Expand Down

0 comments on commit 218e248

Please sign in to comment.