Index: branches/5.3.x/core/units/helpers/recursive_helper.php =================================================================== diff -u -N -r15483 -r15698 --- branches/5.3.x/core/units/helpers/recursive_helper.php (.../recursive_helper.php) (revision 15483) +++ branches/5.3.x/core/units/helpers/recursive_helper.php (.../recursive_helper.php) (revision 15698) @@ -1,6 +1,6 @@ Application->getUnitOption($prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($prefix, 'TableName'); + $config = $this->Application->getUnitConfig($prefix); + $id_field = $config->getIDField(); $sql = 'SELECT '.$id_field.' - FROM '.$table_name.' + FROM '. $config->getTableName() .' WHERE ParentId = '.$category_id; $sub_categories = $this->Conn->GetCol($sql); @@ -32,7 +32,8 @@ } } - $ci_table = $this->Application->getUnitOption('ci', 'TableName'); + $ci_table = $this->Application->getUnitConfig('ci')->getTableName(); + // 1. remove category items from this category if it is supplemental (non-primary) category to them $sql = 'DELETE FROM '.$ci_table.' WHERE ('.$id_field.' = '.$category_id.') AND (PrimaryCat = 0)'; @@ -72,35 +73,35 @@ return Array(); } - $id_field = $this->Application->getUnitOption($prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($prefix, 'TableName'); + $config = $this->Application->getUnitConfig($prefix); - $sql = 'SELECT '.$id_field.' - FROM '.$table_name.' + $sql = 'SELECT '. $config->getIDField() .' + FROM '. $config->getTableName() .' WHERE ResourceId IN ('.implode(',', $resource_ids).')'; return $this->Conn->GetCol($sql); } // moves selected categories to destination category - function MoveCategories($category_ids, $dest_category_id) + function MoveCategories($category_ids, $dst_category_id) { if (!$category_ids) return ; - $id_field = $this->Application->getUnitOption('c', 'IDField'); - $table_name = $this->Application->getUnitOption('c', 'TableName'); + $categories_config = $this->Application->getUnitConfig('c'); + $id_field = $categories_config->getIDField(); + $table_name = $categories_config->getTableName(); // do not move categories into their children $sql = 'SELECT ParentPath FROM '.$table_name.' - WHERE '.$id_field.' = '.$dest_category_id; - $dest_parent_path = explode('|', substr($this->Conn->GetOne($sql), 1, -1)); + WHERE '.$id_field.' = '.$dst_category_id; + $dst_parent_path = explode('|', substr($this->Conn->GetOne($sql), 1, -1)); - $child_categories = array_intersect($dest_parent_path, $category_ids); // get categories, then can't be moved + $child_categories = array_intersect($dst_parent_path, $category_ids); // get categories, then can't be moved $category_ids = array_diff($category_ids, $child_categories); // remove them from movable categories list if ($category_ids) { $sql = 'UPDATE '.$table_name.' - SET ParentId = '.$dest_category_id.' + SET ParentId = '.$dst_category_id.' WHERE '.$id_field.' IN ('.implode(',', $category_ids).')'; $this->Conn->Query($sql); } @@ -131,9 +132,6 @@ $new_category_id = array_pop($temp_handler->CloneItems($prefix, '', Array ($category_id))); $this->Application->SetVar('m_cat_id', $new_category_id); - $id_field = $this->Application->getUnitOption($prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($prefix, 'TableName'); - // 2. assign supplemental items to current category to new category $paste_ids = $this->getCategoryItems($category_id, false); @@ -167,9 +165,11 @@ $temp_handler->CloneItems($item_prefix, '', $item_ids); } + $config = $this->Application->getUnitConfig($prefix); + // 4. do same stuff for each subcategory - $sql = 'SELECT ' . $id_field . ' - FROM ' . $table_name . ' + $sql = 'SELECT ' . $config->getIDField() . ' + FROM ' . $config->getTableName() . ' WHERE ParentId = ' . $category_id; $sub_categories = $this->Conn->GetCol($sql); @@ -191,7 +191,7 @@ */ function getCategoryItems($category_id, $item_primary_category = true) { - $ci_table = $this->Application->getUnitOption('ci', 'TableName'); + $ci_table = $this->Application->getUnitConfig('ci')->getTableName(); $sql = 'SELECT ItemPrefix, ItemResourceId FROM '.$ci_table.'