/** * Detach a category from its parent and destroys category * * @access public * @param CMS_moduleCategory $category * @return boolean true on success, false on failure */ static function detachCategory(&$category) { if (!$category instanceof CMS_moduleCategory) { CMS_grandFather::raiseError("Bad category given, not a valid CMS_moduleCategory instance"); return false; } if ($category->getId() > 0) { $park_integer = CMS_moduleCategory::LINEAGE_PARK_POSITION; //This park position is almost impossible to reach $parentCategory = $category->getParent(); $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmodulesCategories\n\t\t\t\tset\n\t\t\t\t\tuuid_mca={$park_integer},\n\t\t\t\t\tparent_mca={$park_integer},\n\t\t\t\t\troot_mca={$park_integer},\n\t\t\t\t\torder_mca={$park_integer},\n\t\t\t\t\tlineage_mca={$park_integer}\n\t\t\t\twhere\n\t\t\t\t\tid_mca='" . $category->getID() . "'\n\t\t\t"; $q = new CMS_query($sql); if (!$q->hasError()) { if ($parentCategory->getID()) { //if category has a parent (not a root category) return CMS_moduleCategories_catalog::compactSiblingsOrder($parentCategory->getID()); } else { //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $category->getAttribute('moduleCodename'))); CMS_cache::clearTypeCache('polymod'); return true; } } else { CMS_grandFather::raiseError("Detaching category failed"); } } return false; }