/** * @param string $message * @param array|object $resource * @param null|string|Default_Model_User $user */ public function direct($message, $resource, $user = null) { /** @var $log Zend_Log */ $boot = $this->getFrontController()->getParam('bootstrap'); $multilog = $boot->getPluginResource('multiplelog'); $log = $multilog->getLog('audit'); // Assign username if (NULL === $user) { $ident = Zend_Auth::getInstance()->getIdentity(); $user = new UserModel(array('userName' => $ident['username'])); //Impersonation if (isset($ident['impersonation']) && isset($ident['impersonation'])) { UserService::getInstance()->generateImpersonatedUser($user, $ident['impersonation']); } } else { if (!$user instanceof UserModel) { $user = new UserModel(array('userName' => $user)); } } $log->setEventItem('username', $user->userName); if ($user->isImpersonating()) { $log->setEventItem('impersonated', "as " . $user->impersonatingOrgId . " admin"); } // Set the origin flag indicating an external API call if (!empty(\Application\Model\Mapper\OrganizationMapper::$accountingTransactionPrefix) && \Application\Model\Mapper\OrganizationMapper::$accountingTransactionPrefix == 'externalAuth') { $log->setEventItem('origin', 'external'); } else { $log->setEventItem('origin', 'portal'); } // Convert single resources to arrays if (!is_array($resource)) { $resource = array($resource); } // For each given resource log the action foreach ($resource as $res) { $log->setEventItem('resource', (string) $res); $log->audit($message); } }