Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F773387
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 2, 9:53 AM
Size
7 KB
Mime Type
text/x-diff
Expires
Tue, Feb 4, 9:53 AM (1 h, 45 m)
Engine
blob
Format
Raw Data
Handle
556617
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/kernel/include/syscache.php
===================================================================
--- trunk/kernel/include/syscache.php (revision 1088)
+++ trunk/kernel/include/syscache.php (revision 1089)
@@ -1,253 +1,263 @@
<?php
class clsSysCacheItem extends clsItemDB
{
function clsSysCacheItem($id = NULL)
{
$this->clsItemDB();
$this->tablename = GetTablePrefix()."SysCache";
$this->type=12;
$this->BasePermission="";
$this->id_field = "SysCacheId";
$this->NoResourceId=1;
$this->debuglevel=0;
if($id != NULL)
{
if(is_numeric($id))
{
$this->LoadFromDatabase($id);
}
else
$this->LoadByName($name);
}
}
function DetectCahanges($name, $value)
{
}
function LoadFromDatabase($Id)
{
global $Errors;
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->id_field."='%s'",$Id);
$result = $this->adodbConnection->Execute($sql);
if ($result === false || $result->EOF)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return false;
}
$data = $result->fields;
$this->SetFromArray($data);
$this->Clean();
return true;
}
function LoadByName($name)
{
global $Errors;
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE Name ='%s'",$name);
$result = $this->adodbConnection->Execute($sql);
if ($result === false || $result->EOF)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadByName");
return false;
}
$data = $result->fields;
$this->SetFromArray($data);
$this->Clean();
return true;
}
}
class clsSysCacheList extends clsItemCollection
{
function clsSysCacheList()
{
$this->clsItemCollection();
$this->SourceTable=GetTablePrefix()."SysCache";
$this->classname = "clsSysCacheItem";
}
function &GetItemByModule($name, $module, $GroupList="", $LoadFromDB=TRUE)
{
$found=FALSE;
if(is_array($this->Items))
{
foreach($this->Items as $i)
{
if($i->Get("Name")==$name && $i->Get("Module")==$module)
{
$found = TRUE;
break;
}
}
}
if(!$found && $LoadFromDB==TRUE)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE Name = '$name' AND Module='$module' AND GroupList='$GroupList'";
//echo $sql;
$res = $this->adodbConnection->Execute($sql);
if($res && !$res->EOF)
{
$i = $this->AddItemFromArray($res->fields);
$i->tablename = $this->SourceTable;
$i->Clean();
$found = TRUE;
}
else
$i = FALSE;
}
if(!$found)
{
unset($i);
$i = FALSE;
}
return $i;
}
function &GetContextItem($name,$module,$context, $GroupList="", $LoadFromDB=TRUE)
{
$found=FALSE;
if(is_array($this->Items))
{
foreach($this->Items as $i)
{
if($i->Get("Name")==$name && $i->Get("Module")==$module && $i->Get("Context")==$context)
{
$found = TRUE;
break;
}
}
}
if(!$found && $LoadFromDB==TRUE)
{
unset($i);
$sql = "SELECT * FROM ".$this->SourceTable." WHERE Name = '$name' AND Module='$module' AND Context='$context' AND GroupList='$GroupList'";
//echo $sql."<br>\n";
$res = $this->adodbConnection->Execute($sql);
if($res && !$res->EOF)
{
$i = $this->AddItemFromArray($res->fields);
$i->tablename = $this->SourceTable;
$i->Clean();
$found = TRUE;
}
else
$i = FALSE;
}
if(!$found)
{
unset($i);
$i = FALSE;
}
return $i;
}
function &AddCacheItem($name,$value,$module="",$expire=0,$context="",$GroupList="")
{
$i = new clsSysCacheItem();
$i->tablename = $this->SourceTable;
$i->Set(array("Name","Value","Expire","GroupList"),array($name,$value,$expire, $GroupList));
if(strlen($module))
$i->Set("Module",$module);
$i->Set("Context",$context);
- $i->Create();
+ $conn = &GetADODBConnection();
+ $sql = 'SELECT * FROM '.$i->tablename.'
+ WHERE Name="'.$name.'"
+ AND GroupList='.(int)$GroupList.'
+ AND Context="'.$context.'"
+ AND Module="'.$module.'"';
+ $rs = $conn->Execute($sql);
+ if ($rs->EOF)
+ {
+ $i->Create();
+ }
return $i;
}
function &EditCacheItem($name,$value,$module="",$expire=0,$context="",$GroupList="")
{
if(strlen($context))
{
$i =& $this->GetItemByModule($name,$module, $GroupList,TRUE);
}
else
$i =& $this->GetContextItem($name,$module,$context,$GroupList);
if(is_object($i))
{
if($i->Get("Value")!=$value && $name==$i->Get("Name") && $i->Get("Context")==$context &&
$GroupList==$i->Get("GroupList"))
{
$i->Set(array("Name","Value","Expire","GroupList"),array($name,$value,$expire, $GroupList));
if(strlen($module))
$i->Set("Module",$module);
$i->Set("Context",$context);
$i->Update();
}
else
{
$this->AddCacheItem($name,$value,$module,$expire, $context, $GroupList);
}
}
else
{
$this->AddCacheItem($name,$value,$module,$expire, $context, $GroupList);
}
}
function DeleteCacheItem($name,$module="")
{
$i =& $this->GetItemByModule($name,$module,TRUE);
if(is_object($i))
{
$i->Delete();
}
}
function GetContextValue($Name,$Module,$Context="",$GroupList="")
{
$ret = "";
$i =& $this->GetContextItem($Name,$Module,$Context, $GroupList);
if(is_object($i))
$ret = $i->Get("Value");
return $ret;
}
function GetValue($Name,$Module="",$GroupList="")
{
$ret = "";
$i =& $this->GetItemByModule($Name,$Module,$GroupList);
if(is_object($i))
$ret = $i->Get("Value");
return $ret;
}
function PurgeExpired()
{
$sql = "DELETE FROM ".$this->SourceTable." WHERE Expire>0 AND Expire <".date("U");
$this->adodbConnection->Execute($sql);
}
function PurgeCategory($CatId)
{
$sql = "DELETE FROM ".$this->SourceTable." WHERE Context LIKE ':m".$CatId."-%'";
$this->adodbConnection->Execute($sql);
}
function DeleteCachedItem($where)
{
$sql = "DELETE FROM ".$this->SourceTable;
if(strlen($where))
$sql .= " WHERE $where";
$this->adodbConnection->Execute($sql);
//echo $sql."<br>\n";
}
}
?>
Property changes on: trunk/kernel/include/syscache.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Event Timeline
Log In to Comment