clsItemDB(); $this->tablename = GetTablePrefix()."Events"; $this->id_field = "EventId"; $this->NoResourceId=1; $this->debuglevel=0; if($EventId) { $this->LoadFromDatabase($EventId); } } function LoadFromDatabase($Id) { global $Errors; $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 clsEventList extends clsItemCollection { function clsEventList() { $this->clsItemCollection(); $this->classname="clsEvent"; $this->SourceTable = GetTablePrefix()."Events"; $this->PerPageVar = "Perpage_Events"; $this->AdminSearchFields = array("Description", "Module","Event","u.Login"); } function CopyFromEditTable() { global $objSession; $GLOBALS['_CopyFromEditTable']=1; $edit_table = $objSession->GetEditTable($this->SourceTable); $idlist = array(); $sql = "SELECT * FROM $edit_table"; $this->Clear(); $rs = $this->adodbConnection->Execute($sql); while($rs && !$rs->EOF) { $data = $rs->fields; $c = $this->AddItemFromArray($data); if($data["EventId"]>0) { $c->Update(); } $rs->MoveNext(); } unset($GLOBALS['_CopyFromEditTable']); } function PurgeEditTable() { global $objSession; $edit_table = $objSession->GetEditTable($this->SourceTable); $this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); } function &GetEmailEventObject($EventName,$LangId=NULL) { global $objLanguages; if(!$LangId) $LangId = $objLanguages->GetPrimary(); $EmailTable = GetTablePrefix()."EmailMessage"; $EventTable = $this->SourceTable; $sql = "SELECT * FROM $EventTable INNER JOIN $EmailTable ON ($EventTable.EventId = $EmailTable.EventId) "; $sql .="WHERE Event='$EventName' AND LanguageId=$LangId"; $result = $this->adodbConnection->Execute($sql); if ($result === FALSE) { $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"GetEmailEventObject"); return FALSE; } $data = $result->fields; $e = new clsEmailMessage(); $e->SetFromArray($data); $e->Clean(); return $e; } }