Index: trunk/kernel/admin/include/help/export.txt =================================================================== diff -u -N -r55 -r3757 --- trunk/kernel/admin/include/help/export.txt (.../export.txt) (revision 55) +++ trunk/kernel/admin/include/help/export.txt (.../export.txt) (revision 3757) @@ -1 +1,3 @@ -There are no export wizards available in the current version. To export the data, please use your favorite SQL administration utility. One of the most popular utilities for MySQL can be downloaded from http://www.phpmyadmin.net. \ No newline at end of file +

Data export is available from Structure & Data -> Catalog section. Currently we offer Links and Products export into CSV format.

+ +

Alternatively, you may use your favorite SQL administration utility. One of the most popular utilities for MySQL can be downloaded from http://www.phpmyadmin.net.

Index: trunk/core/units/general/cat_dbitem_export.php =================================================================== diff -u -N -r3709 -r3757 --- trunk/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 3709) +++ trunk/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 3757) @@ -5,6 +5,7 @@ class kCatDBItemExportHelper extends kHelper { + var $false = false; var $cache = Array(); @@ -82,24 +83,34 @@ * * @param kEvent $event */ - function fillRequiredFields(&$event) + function fillRequiredFields(&$event, &$object, $set_status = false) { - $object =& $event->getObject(); + if ($object == $this->false) { + $object =& $event->getObject(); + } + $has_empty = false; $fields = array_keys($object->Fields); foreach ($fields as $field_name) { $field_options =& $object->Fields[$field_name]; if (isset($object->VirtualFields[$field_name]) || !getArrayValue($field_options, 'required') ) continue; + if ( $object->GetDBField($field_name) ) continue; $formatter_class = getArrayValue($field_options, 'formatter'); if ($formatter_class) // not tested { $formatter =& $this->Application->recallObject($formatter_class); $sample_value = $formatter->GetSample($field_name, $field_options, $object); } - $object->SetDBField($field_name, isset($sample_value) && $sample_value ? $sample_value : 'dummy'); + + $has_empty = true; + $object->SetDBField($field_name, isset($sample_value) && $sample_value ? $sample_value : 'no value'); } + + if ($set_status && $has_empty) { + $object->SetDBField('Status', 0); + } } /** @@ -115,7 +126,7 @@ return false; } - $this->fillRequiredFields($event); + $this->fillRequiredFields($event, $this->false); $object =& $event->getObject(); $cross_unique_fields = Array('FieldsSeparatedBy', 'FieldsEnclosedBy'); @@ -519,6 +530,10 @@ function setFieldValue($field_index, $value) { + if (empty($value)) { + $value = null; + } + $field_name = $this->exportFields[$field_index]; if (substr($field_name, 0, 7) == 'Custom_') { @@ -559,6 +574,7 @@ function processCurrentItem(&$event) { $tmp_item =& $this->getTempItem($event); + $tmp_item->Clear(); // create/update categories $backup_category_id = $this->Application->GetVar('m_cat_id'); @@ -605,8 +621,11 @@ // create main record $save_method = 'Create'; if ($this->exportOptions['ReplaceDuplicates']) { + $load_keys = Array(); if ($this->exportOptions['CheckDuplicatesMethod'] == 1) { - $load_keys = Array($this->curItem->IDField => $this->curItem->GetID()); + if ($this->curItem->GetID()) { + $load_keys = Array($this->curItem->IDField => $this->curItem->GetID()); + } } else { $key_fields = $this->exportOptions['DuplicateCheckFields']; @@ -615,23 +634,30 @@ } } - $where_clause = ''; - foreach ($load_keys as $field_name => $field_value) { - $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND '; + if (count($load_keys)) { + $where_clause = ''; + foreach ($load_keys as $field_name => $field_value) { + $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND '; + } + $where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause); + + $item_id = $this->getFromCache('new_ids', $where_clause); + if (!$item_id) { + if ($this->exportOptions['CheckDuplicatesMethod'] == 2) { + // by other fields + $parent_path = $this->getParentPath($category_id); + $where_clause = '(c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause; + } + + $sql = 'SELECT '.$this->curItem->IDField.' + FROM '.$this->curItem->TableName.' item_table + LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId + LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId + WHERE '.$where_clause; + $item_id = $this->Conn->GetOne($sql); + } + $save_method = $item_id && $tmp_item->Load($item_id) ? 'Update' : 'Create'; } - $where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause); - - $item_id = $this->getFromCache('new_ids', $where_clause); - if (!$item_id) { - $parent_path = $this->getParentPath($category_id); - $sql = 'SELECT '.$this->curItem->IDField.' - FROM '.$this->curItem->TableName.' item_table - LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId - LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId - WHERE (c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause; - $item_id = $this->Conn->GetOne($sql); - } - $save_method = $item_id && $tmp_item->Load($item_id) ? 'Update' : 'Create'; } $resource_id = $tmp_item->isLoaded() ? $tmp_item->GetDBField('ResourceId') : 0; @@ -641,11 +667,15 @@ $tmp_item->setID($item_id); } + if ($save_method == 'Create') { + $this->fillRequiredFields($this->false, $tmp_item, true); + } + if (!$tmp_item->$save_method()) { return false; } - if ( ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates'] ) { + if ($load_keys && ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates']) { // map new id to old id $this->addToCache('new_ids', $where_clause, $tmp_item->GetID() ); } Index: trunk/kernel/units/general/cat_event_handler.php =================================================================== diff -u -N -r3743 -r3757 --- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3743) +++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3757) @@ -1322,7 +1322,6 @@ } } - $this->Application->StoreVar('ImportCategory', 0); $selected_cats_ids = $this->Application->GetVar('export_categories'); $this->Application->StoreVar($event->Prefix.'_export_ids', $selected_ids ? implode(',', $selected_ids) : '' ); @@ -1658,6 +1657,7 @@ if ($event->Special != 'import' && $event->Special != 'export') return ; $this->setRequiredFields($event); + $this->Application->StoreVar('ImportCategory', 0); } /** Index: trunk/admin/install/upgrades/changelog_1_1_6.txt =================================================================== diff -u -N -r3737 -r3757 --- trunk/admin/install/upgrades/changelog_1_1_6.txt (.../changelog_1_1_6.txt) (revision 3737) +++ trunk/admin/install/upgrades/changelog_1_1_6.txt (.../changelog_1_1_6.txt) (revision 3757) @@ -6,6 +6,7 @@ File in-portal/admin/category/addcategory_permissions.php changed File in-portal/admin/config/addcustomfield.php changed File in-portal/admin/export/.cvsignore is new +File in-portal/admin/help/help.php changed File in-portal/admin/import/step2.php changed File in-portal/admin/import/step3.php changed File in-portal/admin/include/elements.php changed @@ -23,6 +24,8 @@ File in-portal/kernel/constants.php changed File in-portal/kernel/frontaction.php changed File in-portal/kernel/parser.php changed +File in-portal/kernel/admin/include/help/browse.txt changed +File in-portal/kernel/admin/include/help/export.txt changed File in-portal/kernel/admin/include/toolbar/browse.php changed File in-portal/kernel/admin_templates/category_selector.tpl changed File in-portal/kernel/admin_templates/help.tpl changed @@ -155,6 +158,7 @@ Added label "la_OtherFields" of type "1" Added label "la_prompt_max_import_category_levels" of type "1" Added label "la_SeparatedCategoryPath" of type "1" +Added label "la_Text_InDevelopment" of type "1" Added label "la_title_Done" of type "1" Added label "la_type_checkbox" of type "1" Added label "la_Yes" of type "1" Index: trunk/admin/help/help.php =================================================================== diff -u -N -r3076 -r3757 --- trunk/admin/help/help.php (.../help.php) (revision 3076) +++ trunk/admin/help/help.php (.../help.php) (revision 3757) @@ -21,15 +21,21 @@ $section = explode(':', $section); if($section[0] == 'in-portal') $section[0] = 'kernel'; -$topic_path = FULL_PATH.'/'.$section[0].'/'.$admin.'/include/help/'.$section[1].'.txt'; +$help_directory = FULL_PATH.'/'.$section[0].'/'.$admin.'/include/help'; +$topic_path = $help_directory.'/'.$section[1].'.txt'; // for debugging: save new help content if( GetVar('action') == 'save_help' ) { - error_reporting(E_ALL); - $fp = fopen($topic_path, 'w'); - fwrite($fp, stripslashes(GetVar('help_content')) ); - fclose($fp); + $fp = fopen($topic_path, 'w'); + if ($fp) { + fwrite($fp, stripslashes(GetVar('help_content')) ); + fclose($fp); + } + else { + trigger_error('Help file was not saved to '.$topic_path.'', E_USER_WARNING); + } + } $help_data = file_exists($topic_path) ? file_get_contents($topic_path) : GetVar('help_content'); Index: trunk/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r3743 -r3757 --- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3743) +++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3757) @@ -1322,7 +1322,6 @@ } } - $this->Application->StoreVar('ImportCategory', 0); $selected_cats_ids = $this->Application->GetVar('export_categories'); $this->Application->StoreVar($event->Prefix.'_export_ids', $selected_ids ? implode(',', $selected_ids) : '' ); @@ -1658,6 +1657,7 @@ if ($event->Special != 'import' && $event->Special != 'export') return ; $this->setRequiredFields($event); + $this->Application->StoreVar('ImportCategory', 0); } /** Index: trunk/core/units/general/cat_dbitem.php =================================================================== diff -u -N -r3709 -r3757 --- trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3709) +++ trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3757) @@ -59,7 +59,7 @@ function Update($id=null, $system_update=false) { - $this->VirtualFields['ResourceId'] = true; + $this->VirtualFields['ResourceId'] = Array(); $this->SetDBField('Modified', adodb_mktime() ); $this->SetDBField('ModifiedById', $this->Application->GetVar('u_id')); @@ -68,7 +68,10 @@ $this->generateFilename(); } - return parent::Update($id, $system_update); + $ret = parent::Update($id, $system_update); + + unset($this->VirtualFields['ResourceId']); + return $ret; } function checkFilename() @@ -319,16 +322,47 @@ */ function assignToCategory($category_id, $is_primary = false) { - $check_sql = ' SELECT CategoryId - FROM '.TABLE_PREFIX.'CategoryItems - WHERE (ItemResourceId = '.$this->GetDBField('ResourceId').') AND (PrimaryCat = 1)'; - $primary_category_id = $this->Conn->GetOne($check_sql); - if (!$primary_category_id) $is_primary = true; + $table = TABLE_PREFIX.'CategoryItems'; + $key_clause = '(ItemResourceId = '.$this->GetDBField('ResourceId').')'; - if ($primary_category_id == $category_id) return ; + // get all cateories, where item is in + $sql = 'SELECT PrimaryCat, CategoryId FROM '.$table.' WHERE '.$key_clause; + $item_categories = $this->Conn->GetCol($sql, 'CategoryId'); + if (!$item_categories) { + $item_categories = Array(); + $primary_found = false; + } - $sql = 'INSERT INTO '.TABLE_PREFIX.'CategoryItems (CategoryId,ItemResourceId,PrimaryCat) VALUES (%s,%s,%s)'; - $this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0) ); + // find primary category + foreach ($item_categories as $item_category_id => $primary_found) { + if ($primary_found) { + break; + } + } + + if ($primary_found && ($item_category_id == $category_id) && !$is_primary) { + // want to make primary category as non-primary :( + return true; + } + else if (!$primary_found) { + $is_primary = true; + } + + if ($is_primary && $item_categories) { + // reset primary mark from all other categories + $sql = 'UPDATE '.$table.' SET PrimaryCat = 0 WHERE '.$key_clause; + $this->Conn->Query($sql); + } + + // UPDATE & INSERT instead of REPLACE because CategoryItems table has no primary key defined in database + if (isset($item_categories[$category_id])) { + $sql = 'UPDATE '.$table.' SET PrimaryCat = '.($is_primary ? 1 : 0).' WHERE '.$key_clause.' AND (CategoryId = '.$category_id.')'; + $this->Conn->Query($sql); + } + else { + $sql = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat) VALUES (%s,%s,%s)'; + $this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0) ); + } } /** Index: trunk/kernel/admin/include/help/browse.txt =================================================================== diff -u -N -r1440 -r3757 --- trunk/kernel/admin/include/help/browse.txt (.../browse.txt) (revision 1440) +++ trunk/kernel/admin/include/help/browse.txt (.../browse.txt) (revision 3757) @@ -1,4 +1,5 @@

The catalog allows you to navigate the tree of the categories. You will see a navigation bar at the top, which will show you the current category you are in. You may click the category names in the navigation bar to quickly jump up the tree. You may also use the �Up' button (yellow folder with a green up arrow icon) in the toolbar to go one category up, or the �Home' button (house icon) to go all the way up to Home � the root category. To go deeper in the tree, simply click on the desired category.

In side the category, you will see all its subcategories in the top tab, and the items in the bottom tabs.

In this catalog screen, you can create new categories (icon with the folder and a little sun), edit the current category you are in (icon with the folder and a green check mark), create new items (icon looks like the item element icon with a little sun), edit selected categories or items (green check mark) or delete the selected categories or items (red X sign).

+

The catalog section has an Export button (a folder icon with a green arrow to the right). The button is used for exporting items and categories into CSV (comma-separated values) format compatible with most of the spreadsheet applications (such as Microsoft Excel) and other software. You may select one or more categories for the export, or simply click the Export button to export current categories with all sub-categories. Export functionality is currently implemented for Links and Products. The respective export configuration page will open according to the currently selected item tab.

The categories are displayed in two columns. First there is the control check box, then the category icon, also showing the state of the category (new, pending, disabled, etc.), then the category name, then the text state (hot, pop, new, editor�s pick) and the number of subcategories and items that it contains, in parenthesis. Below the category name there is its description and the creation date. \ No newline at end of file Index: trunk/admin/install/langpacks/english.lang =================================================================== diff -u -N -r3711 -r3757 --- trunk/admin/install/langpacks/english.lang (.../english.lang) (revision 3711) +++ trunk/admin/install/langpacks/english.lang (.../english.lang) (revision 3757) @@ -1051,6 +1051,7 @@ SW1hZ2U= SW1hZ2Vz SW5hY3RpdmU= + SW4gRGV2ZWxvcG1lbnQ= SW5zdGFsbA== SW5zdGFsbGVk SW52YWxpZA== Index: trunk/kernel/units/general/cat_dbitem.php =================================================================== diff -u -N -r3709 -r3757 --- trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3709) +++ trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3757) @@ -59,7 +59,7 @@ function Update($id=null, $system_update=false) { - $this->VirtualFields['ResourceId'] = true; + $this->VirtualFields['ResourceId'] = Array(); $this->SetDBField('Modified', adodb_mktime() ); $this->SetDBField('ModifiedById', $this->Application->GetVar('u_id')); @@ -68,7 +68,10 @@ $this->generateFilename(); } - return parent::Update($id, $system_update); + $ret = parent::Update($id, $system_update); + + unset($this->VirtualFields['ResourceId']); + return $ret; } function checkFilename() @@ -319,16 +322,47 @@ */ function assignToCategory($category_id, $is_primary = false) { - $check_sql = ' SELECT CategoryId - FROM '.TABLE_PREFIX.'CategoryItems - WHERE (ItemResourceId = '.$this->GetDBField('ResourceId').') AND (PrimaryCat = 1)'; - $primary_category_id = $this->Conn->GetOne($check_sql); - if (!$primary_category_id) $is_primary = true; + $table = TABLE_PREFIX.'CategoryItems'; + $key_clause = '(ItemResourceId = '.$this->GetDBField('ResourceId').')'; - if ($primary_category_id == $category_id) return ; + // get all cateories, where item is in + $sql = 'SELECT PrimaryCat, CategoryId FROM '.$table.' WHERE '.$key_clause; + $item_categories = $this->Conn->GetCol($sql, 'CategoryId'); + if (!$item_categories) { + $item_categories = Array(); + $primary_found = false; + } - $sql = 'INSERT INTO '.TABLE_PREFIX.'CategoryItems (CategoryId,ItemResourceId,PrimaryCat) VALUES (%s,%s,%s)'; - $this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0) ); + // find primary category + foreach ($item_categories as $item_category_id => $primary_found) { + if ($primary_found) { + break; + } + } + + if ($primary_found && ($item_category_id == $category_id) && !$is_primary) { + // want to make primary category as non-primary :( + return true; + } + else if (!$primary_found) { + $is_primary = true; + } + + if ($is_primary && $item_categories) { + // reset primary mark from all other categories + $sql = 'UPDATE '.$table.' SET PrimaryCat = 0 WHERE '.$key_clause; + $this->Conn->Query($sql); + } + + // UPDATE & INSERT instead of REPLACE because CategoryItems table has no primary key defined in database + if (isset($item_categories[$category_id])) { + $sql = 'UPDATE '.$table.' SET PrimaryCat = '.($is_primary ? 1 : 0).' WHERE '.$key_clause.' AND (CategoryId = '.$category_id.')'; + $this->Conn->Query($sql); + } + else { + $sql = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat) VALUES (%s,%s,%s)'; + $this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0) ); + } } /** Index: trunk/admin/install/inportal_remove.sql =================================================================== diff -u -N -r2826 -r3757 --- trunk/admin/install/inportal_remove.sql (.../inportal_remove.sql) (revision 2826) +++ trunk/admin/install/inportal_remove.sql (.../inportal_remove.sql) (revision 3757) @@ -88,7 +88,7 @@ # -------------------------------------------------------- DROP TABLE Pages # -------------------------------------------------------- -DROP TABLE PageContent +DROP TABLE PageContent # -------------------------------------------------------- DROP TABLE BanRules # -------------------------------------------------------- @@ -189,4 +189,8 @@ DROP TABLE UserSession # -------------------------------------------------------- DROP TABLE Visits +# -------------------------------------------------------- +DROP TABLE ProductOptions +# -------------------------------------------------------- +DROP TABLE ProductOptionCombinations # \ No newline at end of file Index: trunk/kernel/units/general/cat_dbitem_export.php =================================================================== diff -u -N -r3709 -r3757 --- trunk/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 3709) +++ trunk/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 3757) @@ -5,6 +5,7 @@ class kCatDBItemExportHelper extends kHelper { + var $false = false; var $cache = Array(); @@ -82,24 +83,34 @@ * * @param kEvent $event */ - function fillRequiredFields(&$event) + function fillRequiredFields(&$event, &$object, $set_status = false) { - $object =& $event->getObject(); + if ($object == $this->false) { + $object =& $event->getObject(); + } + $has_empty = false; $fields = array_keys($object->Fields); foreach ($fields as $field_name) { $field_options =& $object->Fields[$field_name]; if (isset($object->VirtualFields[$field_name]) || !getArrayValue($field_options, 'required') ) continue; + if ( $object->GetDBField($field_name) ) continue; $formatter_class = getArrayValue($field_options, 'formatter'); if ($formatter_class) // not tested { $formatter =& $this->Application->recallObject($formatter_class); $sample_value = $formatter->GetSample($field_name, $field_options, $object); } - $object->SetDBField($field_name, isset($sample_value) && $sample_value ? $sample_value : 'dummy'); + + $has_empty = true; + $object->SetDBField($field_name, isset($sample_value) && $sample_value ? $sample_value : 'no value'); } + + if ($set_status && $has_empty) { + $object->SetDBField('Status', 0); + } } /** @@ -115,7 +126,7 @@ return false; } - $this->fillRequiredFields($event); + $this->fillRequiredFields($event, $this->false); $object =& $event->getObject(); $cross_unique_fields = Array('FieldsSeparatedBy', 'FieldsEnclosedBy'); @@ -519,6 +530,10 @@ function setFieldValue($field_index, $value) { + if (empty($value)) { + $value = null; + } + $field_name = $this->exportFields[$field_index]; if (substr($field_name, 0, 7) == 'Custom_') { @@ -559,6 +574,7 @@ function processCurrentItem(&$event) { $tmp_item =& $this->getTempItem($event); + $tmp_item->Clear(); // create/update categories $backup_category_id = $this->Application->GetVar('m_cat_id'); @@ -605,8 +621,11 @@ // create main record $save_method = 'Create'; if ($this->exportOptions['ReplaceDuplicates']) { + $load_keys = Array(); if ($this->exportOptions['CheckDuplicatesMethod'] == 1) { - $load_keys = Array($this->curItem->IDField => $this->curItem->GetID()); + if ($this->curItem->GetID()) { + $load_keys = Array($this->curItem->IDField => $this->curItem->GetID()); + } } else { $key_fields = $this->exportOptions['DuplicateCheckFields']; @@ -615,23 +634,30 @@ } } - $where_clause = ''; - foreach ($load_keys as $field_name => $field_value) { - $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND '; + if (count($load_keys)) { + $where_clause = ''; + foreach ($load_keys as $field_name => $field_value) { + $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND '; + } + $where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause); + + $item_id = $this->getFromCache('new_ids', $where_clause); + if (!$item_id) { + if ($this->exportOptions['CheckDuplicatesMethod'] == 2) { + // by other fields + $parent_path = $this->getParentPath($category_id); + $where_clause = '(c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause; + } + + $sql = 'SELECT '.$this->curItem->IDField.' + FROM '.$this->curItem->TableName.' item_table + LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId + LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId + WHERE '.$where_clause; + $item_id = $this->Conn->GetOne($sql); + } + $save_method = $item_id && $tmp_item->Load($item_id) ? 'Update' : 'Create'; } - $where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause); - - $item_id = $this->getFromCache('new_ids', $where_clause); - if (!$item_id) { - $parent_path = $this->getParentPath($category_id); - $sql = 'SELECT '.$this->curItem->IDField.' - FROM '.$this->curItem->TableName.' item_table - LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId - LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId - WHERE (c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause; - $item_id = $this->Conn->GetOne($sql); - } - $save_method = $item_id && $tmp_item->Load($item_id) ? 'Update' : 'Create'; } $resource_id = $tmp_item->isLoaded() ? $tmp_item->GetDBField('ResourceId') : 0; @@ -641,11 +667,15 @@ $tmp_item->setID($item_id); } + if ($save_method == 'Create') { + $this->fillRequiredFields($this->false, $tmp_item, true); + } + if (!$tmp_item->$save_method()) { return false; } - if ( ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates'] ) { + if ($load_keys && ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates']) { // map new id to old id $this->addToCache('new_ids', $where_clause, $tmp_item->GetID() ); }