本文整理汇总了PHP中AuditEvent::save方法的典型用法代码示例。如果您正苦于以下问题:PHP AuditEvent::save方法的具体用法?PHP AuditEvent::save怎么用?PHP AuditEvent::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuditEvent
的用法示例。
在下文中一共展示了AuditEvent::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logAuditEvent
public static function logAuditEvent($moduleName, $eventName, $data = null, RedBeanModel $model = null, User $user = null)
{
assert('is_string($moduleName) && $moduleName != ""');
assert('is_string($eventName) && $eventName != ""');
if ($user === null) {
$user = Yii::app()->user->userModel;
if (!$user instanceof User) {
throw new NoCurrentUserSecurityException();
}
}
if ($eventName == "Item Viewed") {
AuditEventsRecentlyViewedUtil::resolveNewRecentlyViewedModel($data[1], $model, AuditEventsRecentlyViewedUtil::RECENTLY_VIEWED_COUNT + 1);
}
if ($eventName == "Item Deleted") {
$modelClassName = get_class($model);
AuditEventsRecentlyViewedUtil::deleteModelFromRecentlyViewed($modelClassName::getModuleClassName(), $model);
}
if (!AuditEvent::$isTableOptimized && !AUDITING_OPTIMIZED) {
$auditEvent = new AuditEvent();
$auditEvent->dateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
$auditEvent->moduleName = $moduleName;
$auditEvent->eventName = $eventName;
$auditEvent->user = $user;
$auditEvent->modelClassName = $model !== null ? get_class($model) : null;
$auditEvent->modelId = $model !== null ? $model->id : null;
$auditEvent->serializedData = serialize($data);
$saved = $auditEvent->save();
AuditEvent::$isTableOptimized = true;
} else {
$sql = "insert into auditevent (datetime,\n modulename,\n eventname,\n _user_id,\n modelclassname,\n modelid,\n serializeddata)\n values ('" . DateTimeUtil::convertTimestampToDbFormatDateTime(time()) . "',\n '{$moduleName}',\n '{$eventName}',\n {$user->id}, " . ($model !== null ? "'" . get_class($model) . "', " : 'null, ') . ($model !== null ? "{$model->id}, " : 'null, ') . ":data)";
ZurmoRedBean::exec($sql, array('data' => serialize($data))) !== null;
$saved = true;
}
return $saved;
}