本文整理汇总了PHP中LogModel::logChange方法的典型用法代码示例。如果您正苦于以下问题:PHP LogModel::logChange方法的具体用法?PHP LogModel::logChange怎么用?PHP LogModel::logChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogModel
的用法示例。
在下文中一共展示了LogModel::logChange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
//.........这里部分代码省略.........
$Fields = $this->Validation->schemaValidationFields();
// Check for spam.
$spam = SpamModel::isSpam('Discussion', $Fields);
if ($spam) {
return SPAM;
}
// Get DiscussionID if one was sent
$DiscussionID = intval(val('DiscussionID', $Fields, 0));
// Remove the primary key from the fields for saving.
unset($Fields['DiscussionID']);
$StoredCategoryID = false;
if ($DiscussionID > 0) {
// Updating
$Stored = $this->getID($DiscussionID, DATASET_TYPE_OBJECT);
// Block Format change if we're forcing the formatter.
if (c('Garden.ForceInputFormatter')) {
unset($Fields['Format']);
}
// Clear the cache if necessary.
$CacheKeys = array();
if (val('Announce', $Stored) != val('Announce', $Fields)) {
$CacheKeys[] = $this->getAnnouncementCacheKey();
$CacheKeys[] = $this->getAnnouncementCacheKey(val('CategoryID', $Stored));
}
if (val('CategoryID', $Stored) != val('CategoryID', $Fields)) {
$CacheKeys[] = $this->getAnnouncementCacheKey(val('CategoryID', $Fields));
}
foreach ($CacheKeys as $CacheKey) {
Gdn::cache()->remove($CacheKey);
}
self::serializeRow($Fields);
$this->SQL->put($this->Name, $Fields, array($this->PrimaryKey => $DiscussionID));
setValue('DiscussionID', $Fields, $DiscussionID);
LogModel::logChange('Edit', 'Discussion', (array) $Fields, $Stored);
if (val('CategoryID', $Stored) != val('CategoryID', $Fields)) {
$StoredCategoryID = val('CategoryID', $Stored);
}
} else {
// Inserting.
if (!val('Format', $Fields) || c('Garden.ForceInputFormatter')) {
$Fields['Format'] = c('Garden.InputFormatter', '');
}
if (c('Vanilla.QueueNotifications')) {
$Fields['Notified'] = ActivityModel::SENT_PENDING;
}
// Check for approval
$ApprovalRequired = checkRestriction('Vanilla.Approval.Require');
if ($ApprovalRequired && !val('Verified', Gdn::session()->User)) {
LogModel::insert('Pending', 'Discussion', $Fields);
return UNAPPROVED;
}
// Create discussion
$this->serializeRow($Fields);
$DiscussionID = $this->SQL->insert($this->Name, $Fields);
$Fields['DiscussionID'] = $DiscussionID;
// Update the cache.
if ($DiscussionID && Gdn::cache()->activeEnabled()) {
$CategoryCache = array('LastDiscussionID' => $DiscussionID, 'LastCommentID' => null, 'LastTitle' => Gdn_Format::text($Fields['Name']), 'LastUserID' => $Fields['InsertUserID'], 'LastDateInserted' => $Fields['DateInserted'], 'LastUrl' => DiscussionUrl($Fields));
CategoryModel::setCache($Fields['CategoryID'], $CategoryCache);
// Clear the cache if necessary.
if (val('Announce', $Fields)) {
Gdn::cache()->remove($this->getAnnouncementCacheKey(val('CategoryID', $Fields)));
if (val('Announce', $Fields) == 1) {
Gdn::cache()->remove($this->getAnnouncementCacheKey());
}
}