Index: trunk/kernel/include/parseditem.php
===================================================================
diff -u -N -r988 -r1009
--- trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 988)
+++ trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 1009)
@@ -1206,6 +1206,7 @@
$c->SetFromArray($data);
$c->idfield = $idfield;
$c->Dirty();
+
if($c->Get($idfield) < 1)
{
$old_id = $c->Get($idfield);
@@ -1227,6 +1228,7 @@
}
$c->Create();
}
+ $item_ids[]=$c->UniqueId(); // save item id for future use
if(is_numeric($c->Get("ResourceId")))
{
if( isset($c->Related) && is_object($c->Related) )
@@ -1290,6 +1292,8 @@
if($edit_table) @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$objSession->GetEditTable("CategoryItems"));
unset($GLOBALS['_CopyFromEditTable']);
+
+ return $item_ids;
}
function GetNextTempID()
@@ -2126,38 +2130,24 @@
return $ExtraId;
}
+
+ /**
+ * Return all listype (from tags) to id mappings
+ *
+ * @return Array
+ * @access private
+ */
+ function GetListTypes()
+ {
+ return Array( '_'=>0,'category'=>1,'myitems'=>2,'hot'=>3,'pop'=>4,
+ 'pick'=>5,'favorites'=>6,'new'=>8);
+ }
+
function CacheListType($ListType)
{
- if(!strlen($ListType))
- $ListType="_";
- switch($ListType)
- {
- case "_":
- $ListTypeId = 0;
- break;
- case "category":
- $ListTypeId = 1;
- break;
- case "myitems":
- $ListTypeId = 2;
- break;
- case "hot":
- $ListTypeId = 3;
- break;
- case "pop":
- $ListTypeId = 4;
- break;
- case "pick":
- $ListTypeId = 5;
- break;
- case "favorites":
- $ListTypeId = 6;
- break;
- case "new":
- $ListTypeId = 8;
- break;
- }
- return $ListTypeId;
+ if($ListType) $ListType='_';
+ $mapping=$this->GetListTypes();
+ return $mapping[$ListType];
}
function PerformItemCount($attribs=array())
@@ -2838,7 +2828,25 @@
}
}
-
+
+ /**
+ * Updates count cache for selected ids in list
+ *
+ * @param Array $item_ids
+ * @access protected
+ */
+ function FlushCache($item_ids)
+ {
+ $db =& GetADODBConnection();
+ if(is_array($item_ids)) $item_ids=implode(',',$item_ids);
+
+ $sql = 'SELECT ResourceId FROM '.$this->SourceTable.' WHERE '.$this->GetIDField().' IN ('.$item_ids.')';
+ $resource_ids=$db->GetCol($sql);
+ $sql='SELECT CategoryId FROM '.GetTablePrefix().'CategoryItems WHERE ItemResourceId IN ('.implode(',',$resource_ids).')';
+ $cat_ids=$db->GetCol($sql);
+ UpdateCategoryCount($this->ItemType, $cat_ids, $this->GetListTypes());
+ }
+
function PasteFromClipboard($TargetCat,$NameField="")
{
global $objSession,$objCatList;
@@ -2863,7 +2871,7 @@
{
$item->CopyToNewResource($TargetCat,$NameField); // create item copy, but with new ResourceId
$item->AddToCategory($TargetCat);
- UpdateCategoryCount($item->type,$TargetCat);
+ UpdateCategoryCount($item->type,$TargetCat, $this->GetListTypes() );
}
}
Index: trunk/kernel/include/syscache.php
===================================================================
diff -u -N -r889 -r1009
--- trunk/kernel/include/syscache.php (.../syscache.php) (revision 889)
+++ trunk/kernel/include/syscache.php (.../syscache.php) (revision 1009)
@@ -124,7 +124,7 @@
foreach($this->Items as $i)
{
if($i->Get("Name")==$name && $i->Get("Module")==$module && $i->Get("Context")==$context)
- {
+ {
$found = TRUE;
break;
}
@@ -136,6 +136,7 @@
{
unset($i);
$sql = "SELECT * FROM ".$this->SourceTable." WHERE Name = '$name' AND Module='$module' AND Context='$context' AND GroupList='$GroupList'";
+
//echo $sql."
\n";
$res = $this->adodbConnection->Execute($sql);
Index: trunk/kernel/include/category.php
===================================================================
diff -u -N -r916 -r1009
--- trunk/kernel/include/category.php (.../category.php) (revision 916)
+++ trunk/kernel/include/category.php (.../category.php) (revision 1009)
@@ -40,9 +40,10 @@
function ClearCacheData()
{
- $env = "':m".$this->Get("CategoryId")."%'";
+ /*$env = "':m".$this->Get("CategoryId")."%'";
+ DeleteTagCache("m_list_cats","",$env); */
DeleteTagCache("m_itemcount","Category%");
- DeleteTagCache("m_list_cats","",$env);
+ DeleteModuleTagCache('kernel');
}
function DetectChanges($name, $value)
@@ -1363,7 +1364,8 @@
return $res;
}
- function UpdateCacheCounts()
+// not used anywhere
+ /* function UpdateCacheCounts()
{
global $objItemTypes;
@@ -1374,7 +1376,7 @@
//echo "Updating count for ".$this->Get("CachedNavbar")."
\n";
UpdateCategoryCount(0,$CatId);
}
- }
+ }*/
/**
* @return void
Index: trunk/kernel/action.php
===================================================================
diff -u -N -r985 -r1009
--- trunk/kernel/action.php (.../action.php) (revision 985)
+++ trunk/kernel/action.php (.../action.php) (revision 1009)
@@ -551,10 +551,11 @@
}
break;
- case "m_item_recount":
+ // not used anywhere
+/* case "m_item_recount":
if($ro_perm) break;
RunDown($m_var_list["cat"],"UpdateCacheCounts");
- break;
+ break; */
case "m_cat_delete":
if($ro_perm) break;