oSystem=&$oSystem; } function gbDelete($sTable,$lPrimaryKey) { if($oTableInfo=$this->oSystem->oDB->goGetTableInfo($sTable)) { if($oTableInfo->gbRecordDeletable()) { // testen ob der datensatz bekannt ist und dem benutzer gehört! $bCanBeDeleted=$this->gbOwnedByCurrentClient($sTable,$lPrimaryKey,&$oTableInfo); if($bCanBeDeleted) { if($oResult=$this->oSystem->oDB->goQuery("UPDATE ".$sTable." SET DeleteDate=NOW(),DeletedBy=".$this->oSystem->oUser->oUserData->UserPK." WHERE ".$oTableInfo->PrimaryKey."=".$lPrimaryKey)) { if($oResult->glGetAffectedRows()==1) { // löschung vorgenommen loggen } else { // datensatz nicht gefunden! } } } else { // misuse, critical log! inform MASTER } } else { // nicht löschbar } } } function gbOwnedByUser($sTable,$lPrimaryKey,$sKeyField=false) { $oTableInfo=$this->oSystem->oDB->goGetTableInfo($sTable); $sUserPKField=$this->oSystem->oUser-> $sKeyField=$sKeyField===false?$oTableInfo->PrimaryKey:$sKeyField; if($oTableInfo->gbFieldExists("UserPK")) { $lNumberOfOwnedRecords=$this->oSystem->oDB->glGetNumberOfRecords($sTable,$sKeyField."=".$lPrimaryKey." AND ".$sUserPKField."=".$this->oSystem->oUser->oUserData->UserPK); return $lNumberOfOwnedRecords>0; } return false; } function gbOwnedByCurrentClient($sTable,$lPrimaryKey,$oTableInfo=false) { if($oTableInfo===false) $oTableInfo=$this->oSystem->oDB->goGetTableInfo($sTable); echo mysql_error(); if($oTableInfo->gbFieldExists("ClientPK")) { if($lRecordOwnedByClient=$this->oSystem->oDB->gsGetFieldValue($oTableInfo->Table,"ClientPK",$oTableInfo->PrimaryKey."=".$lPrimaryKey)) { return $lRecordOwnedByClient==$this->oSystem->oUser->oUserData->ClientPK; } return false; } return false; } }