Index: trunk/kernel/include/searchitems.php
===================================================================
diff -u -r271 -r402
--- trunk/kernel/include/searchitems.php (.../searchitems.php) (revision 271)
+++ trunk/kernel/include/searchitems.php (.../searchitems.php) (revision 402)
@@ -88,6 +88,88 @@
}
}
+class clsEmailLog extends clsItemDB
+{
+ function clsEmailLog($id=NULL)
+ {
+ $this->clsItemDB();
+ $this->tablename = GetTablePrefix()."SearchLog";
+ $this->id_field = "SearchLogId";
+ $this->NoResourceId = 1;
+ if($id)
+ $this->LoadFromDatabase($id);
+ }
+
+ function LoadFromDatabase($Id)
+ {
+ global $Errors;
+
+ if(!isset($Id))
+ {
+ $Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase");
+ return false;
+ }
+ $sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->IdField()." = '%s'",$Id);
+ $result = $this->adodbConnection->Execute($sql);
+ if ($result === false)
+ {
+ $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
+ return false;
+ }
+
+ $data = $result->fields;
+
+ $this->SetFromArray($data);
+ $this->Clean();
+ return true;
+ }
+}
+
+class clsEmailLogList extends clsItemCollection
+{
+ var $Page;
+ var $PerPageVar;
+
+ function clsEmailLogList()
+ {
+ $this->clsItemCollection();
+ $this->SourceTable = GetTablePrefix()."SearchLog";
+ $this->classname = "clsEmailLog";
+ $this->Page=1;
+ $this->PerPageVar = "Perpage_EmailsL";
+ $this->AdminSearchFields = array("event", "fromuser", "addressto", "subject");
+ }
+
+ function UpdateKeyword($keyword,$SearchType)
+ {
+ $sql = "UPDATE ".$this->SourceTable." SET Indices = Indices+1 WHERE Keyword='$keyword' AND SearchType=$SearchType";
+ //echo $sql."
\n";
+ $this->adodbConnection->Execute($sql);
+ if($this->adodbConnection->Affected_Rows()==0)
+ {
+ //echo "Creating Keyword record..
\n";
+ $k = new clsSearchLog();
+ $k->Set("Keyword",$keyword);
+ $k->Set("Indices",1);
+ $k->Set("SearchType",$SearchType);
+ $k->Create();
+ }
+ }
+
+ function AddKeywords($Keywords)
+ {
+ if(is_array($Keywords))
+ {
+ for($i=0;$iUpdateKeyword($Keywords[$i]);
+ }
+ }
+ else
+ $this->UpdateKeyword($Keywords);
+ }
+}
+
class clsSearchResults extends clsItemCollection
{
var $ResultTable;