Index: trunk/globals.php =================================================================== diff -u -r984 -r1013 --- trunk/globals.php (.../globals.php) (revision 984) +++ trunk/globals.php (.../globals.php) (revision 1013) @@ -962,25 +962,76 @@ } -function UpdateCategoryCount($ItemTypeName=0,$ListType=NULL) +function UpdateCategoryCount($item_type,$CategoriesIds,$ListType='') { global $objCountCache, $objItemTypes; - - if(is_numeric($ItemTypeName)) - $item = $objItemTypes->GetItem($ItemTypeName); - else - $item = $objItemTypes->GetTypeByName($ItemTypeName); + $db=&GetADODBConnection(); + if( !is_numeric($item_type) ) + { + $sql = 'SELECT ItemType FROM '.$objItemTypes->SourceTable.' WHERE ItemName=\''.$item_type.'\''; + $item_type=$db->GetOne($sql); + } + if($item_type) + { + if(is_array($CategoriesIds)) + { + $CategoriesIds=implode(',',$CategoriesIds); + } + if(!is_array($ListType)) $ListType=Array($ListType=>'opa'); + + $sql = 'SELECT ParentPath FROM '.GetTablePrefix().'Category WHERE CategoryId IN ('.$CategoriesIds.')'; + $rs = $db->Execute($sql); + $parents = Array(); + while (!$rs->EOF) + { + $tmp=$rs->fields['ParentPath']; + $tmp=substr($tmp,1,strlen($tmp)-2); + $tmp=explode('|',$tmp); + foreach ($tmp as $tmp_cat_id) { + $parents[$tmp_cat_id]=1; + } + $rs->MoveNext(); + } + $parents=array_keys($parents); + $list_types=array_keys($ListType); + foreach($parents as $ParentCategoryId) + { + foreach ($list_types as $list_type) { + $objCountCache->DeleteValue($list_type, $item_type, $ParentCategoryId, 0); // total count + $objCountCache->DeleteValue($list_type, $item_type, $ParentCategoryId, 1); // total count today + } + } + } + else + { + die('wrong item type passed to "UpdateCategoryCount"'); + } - if(is_object($item)) +/* if(is_object($item)) { $ItemType = $item->Get("ItemType"); $sql = "DELETE FROM ".$objCountCache->SourceTable." WHERE ItemType=$ItemType"; if( is_numeric($ListType) ) $sql .= " AND ListType=$ListType"; $objCountCache->adodbConnection->Execute($sql); - } + } */ } +function ResetCache($CategoryId) +{ + global $objCountCache; + $db =& GetADODBConnection(); + $sql = 'SELECT ParentPath FROM '.GetTablePrefix().'Category WHERE CategoryId = '.$CategoryId; + $parents = $db->GetOne($sql); + $parents = substr($parents,1,strlen($parents)-2); + $parents = explode('|',$parents); + foreach($parents as $ParentCategoryId) + { + $objCountCache->DeleteValue('_', TYPE_TOPIC, $ParentCategoryId, 0); // total topic count + $objCountCache->DeleteValue('_', TYPE_TOPIC, $ParentCategoryId, 1); // total + } +} + function UpdateModifiedCategoryCount($ItemTypeName,$CatId=NULL,$Modifier=0,$ExtraId=NULL) { } @@ -1041,6 +1092,52 @@ } } +/** + * Deletes whole tag cache for + * selected module + * + * @param string $module + * @param string $name + * @access public + */ +function DeleteModuleTagCache($module, $tagname='') +{ + global $objSystemCache, $objConfig; + + if($objConfig->Get("SystemTagCache")) + { + $where = 'Module LIKE \''.$module.'\''; + if(strlen($tagname)) + { + $where .= ' AND Name LIKE \''.$tagname.'\''; + } + $objSystemCache->DeleteCachedItem($where); + } +} + + + +/*function ClearTagCache() +{ + global $objSystemCache, $objConfig; + + if($objConfig->Get("SystemTagCache")) + { + $where = ''; + $objSystemCache->DeleteCachedItem($where); + } +}*/ + +/*function EraseCountCache() +{ +// global $objSystemCache, $objConfig; + + $db =& GetADODBConnection(); + $sql = 'DELETE * FROM '.GetTablePrefix().'CountCache'; + return $db->Execute($sql) ? true : false; +}*/ + + function ParseTagLibrary() { $objTagList = new clsTagList();