/** * @param BaseObject $object * @return AuditTrail */ public function createAuditTrail(BaseObject $object, $action) { $partnerId = kCurrentContext::$master_partner_id; if (!$this->traceEnabled($partnerId)) { return null; } if (!method_exists($object, 'getPeer') || !method_exists($object, 'getId')) { return null; } $peer = $object->getPeer(); try { $objectType = $peer->getOMClass(false, null); } catch (Exception $e) { KalturaLog::err("Error creating audit trail for object id[" . $object->getId() . "] type[{$objectType}] " . $e->getMessage()); $auditTrail = null; return null; } if (!in_array($objectType, AuditTrail::getAllwodObjectTypes())) { return null; } try { $auditTrail = new AuditTrail(); $auditTrail->setAction($action); $auditTrail->setPartnerId($partnerId); $auditTrail->setObjectType($objectType); $auditTrail->setStatus(AuditTrail::AUDIT_TRAIL_STATUS_READY); $auditTrail->setObjectId($object->getId()); $auditTrail->setEntryId($this->getEntryId($object)); self::setRelatedObject($auditTrail, $object); } catch (kAuditTrailException $e) { KalturaLog::err("Error creating audit trail for object id[" . $object->getId() . "] type[{$objectType}] " . $e->getMessage()); $auditTrail = null; } return $auditTrail; }