当前位置: 首页>>代码示例>>PHP>>正文


PHP LogModel::LogChange方法代码示例

本文整理汇总了PHP中LogModel::LogChange方法的典型用法代码示例。如果您正苦于以下问题:PHP LogModel::LogChange方法的具体用法?PHP LogModel::LogChange怎么用?PHP LogModel::LogChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogModel的用法示例。


在下文中一共展示了LogModel::LogChange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * Insert or update core data about the comment.
  *
  * Events: BeforeSaveComment, AfterSaveComment.
  *
  * @since 2.0.0
  * @access public
  *
  * @param array $FormPostValues Data from the form model.
  * @return int $CommentID
  */
 public function save($FormPostValues)
 {
     $Session = Gdn::session();
     // Define the primary key in this model's table.
     $this->defineSchema();
     // Add & apply any extra validation rules:
     $this->Validation->applyRule('Body', 'Required');
     $this->Validation->addRule('MeAction', 'function:ValidateMeAction');
     $this->Validation->applyRule('Body', 'MeAction');
     $MaxCommentLength = Gdn::config('Vanilla.Comment.MaxLength');
     if (is_numeric($MaxCommentLength) && $MaxCommentLength > 0) {
         $this->Validation->SetSchemaProperty('Body', 'Length', $MaxCommentLength);
         $this->Validation->applyRule('Body', 'Length');
     }
     $MinCommentLength = c('Vanilla.Comment.MinLength');
     if ($MinCommentLength && is_numeric($MinCommentLength)) {
         $this->Validation->SetSchemaProperty('Body', 'MinLength', $MinCommentLength);
         $this->Validation->addRule('MinTextLength', 'function:ValidateMinTextLength');
         $this->Validation->applyRule('Body', 'MinTextLength');
     }
     // Validate $CommentID and whether this is an insert
     $CommentID = val('CommentID', $FormPostValues);
     $CommentID = is_numeric($CommentID) && $CommentID > 0 ? $CommentID : false;
     $Insert = $CommentID === false;
     if ($Insert) {
         $this->AddInsertFields($FormPostValues);
     } else {
         $this->AddUpdateFields($FormPostValues);
     }
     // Prep and fire event
     $this->EventArguments['FormPostValues'] =& $FormPostValues;
     $this->EventArguments['CommentID'] = $CommentID;
     $this->fireEvent('BeforeSaveComment');
     // Validate the form posted values
     if ($this->validate($FormPostValues, $Insert)) {
         // If the post is new and it validates, check for spam
         if (!$Insert || !$this->CheckForSpam('Comment')) {
             $Fields = $this->Validation->SchemaValidationFields();
             $Fields = RemoveKeyFromArray($Fields, $this->PrimaryKey);
             if ($Insert === false) {
                 // Log the save.
                 LogModel::LogChange('Edit', 'Comment', array_merge($Fields, array('CommentID' => $CommentID)));
                 // Save the new value.
                 $this->SerializeRow($Fields);
                 $this->SQL->put($this->Name, $Fields, array('CommentID' => $CommentID));
             } else {
                 // Make sure that the comments get formatted in the method defined by Garden.
                 if (!val('Format', $Fields) || c('Garden.ForceInputFormatter')) {
                     $Fields['Format'] = Gdn::config('Garden.InputFormatter', '');
                 }
                 // Check for spam
                 $Spam = SpamModel::IsSpam('Comment', $Fields);
                 if ($Spam) {
                     return SPAM;
                 }
                 // Check for approval
                 $ApprovalRequired = CheckRestriction('Vanilla.Approval.Require');
                 if ($ApprovalRequired && !val('Verified', Gdn::session()->User)) {
                     $DiscussionModel = new DiscussionModel();
                     $Discussion = $DiscussionModel->getID(val('DiscussionID', $Fields));
                     $Fields['CategoryID'] = val('CategoryID', $Discussion);
                     LogModel::insert('Pending', 'Comment', $Fields);
                     return UNAPPROVED;
                 }
                 // Create comment.
                 $this->SerializeRow($Fields);
                 $CommentID = $this->SQL->insert($this->Name, $Fields);
             }
             if ($CommentID) {
                 $this->EventArguments['CommentID'] = $CommentID;
                 $this->EventArguments['Insert'] = $Insert;
                 // IsNewDiscussion is passed when the first comment for new discussions are created.
                 $this->EventArguments['IsNewDiscussion'] = val('IsNewDiscussion', $FormPostValues);
                 $this->fireEvent('AfterSaveComment');
             }
         }
     }
     // Update discussion's comment count
     $DiscussionID = val('DiscussionID', $FormPostValues);
     $this->UpdateCommentCount($DiscussionID, array('Slave' => false));
     return $CommentID;
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:93,代码来源:class.commentmodel.php

示例2: Save


//.........这里部分代码省略.........
     //	Prep and fire event
     $this->EventArguments['FormPostValues'] =& $FormPostValues;
     $this->EventArguments['DiscussionID'] = $DiscussionID;
     $this->FireEvent('BeforeSaveDiscussion');
     // Validate the form posted values
     $this->Validate($FormPostValues, $Insert);
     $ValidationResults = $this->ValidationResults();
     // If the body is not required, remove it's validation errors.
     $BodyRequired = C('Vanilla.DiscussionBody.Required', TRUE);
     if (!$BodyRequired && array_key_exists('Body', $ValidationResults)) {
         unset($ValidationResults['Body']);
     }
     if (count($ValidationResults) == 0) {
         // If the post is new and it validates, make sure the user isn't spamming
         if (!$Insert || !$this->CheckForSpam('Discussion')) {
             // Get all fields on the form that relate to the schema
             $Fields = $this->Validation->SchemaValidationFields();
             // Get DiscussionID if one was sent
             $DiscussionID = intval(ArrayValue('DiscussionID', $Fields, 0));
             // Remove the primary key from the fields for saving
             $Fields = RemoveKeyFromArray($Fields, 'DiscussionID');
             $StoredCategoryID = FALSE;
             if ($DiscussionID > 0) {
                 // Updating
                 $Stored = $this->GetID($DiscussionID, DATASET_TYPE_ARRAY);
                 // Clear the cache if necessary.
                 if (GetValue('Announce', $Stored) != GetValue('Announce', $Fields)) {
                     $CacheKeys = array('Announcements');
                     $this->SQL->Cache($CacheKeys);
                 }
                 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 (GetValue('CategoryID', $Stored) != GetValue('CategoryID', $Fields)) {
                     $StoredCategoryID = GetValue('CategoryID', $Stored);
                 }
             } else {
                 // Inserting.
                 if (!GetValue('Format', $Fields) || C('Garden.ForceInputFormatter')) {
                     $Fields['Format'] = C('Garden.InputFormatter', '');
                 }
                 if (C('Vanilla.QueueNotifications')) {
                     $Fields['Notified'] = ActivityModel::SENT_PENDING;
                 }
                 // Check for spam.
                 $Spam = SpamModel::IsSpam('Discussion', $Fields);
                 if ($Spam) {
                     return SPAM;
                 }
                 // Check for approval
                 $ApprovalRequired = CheckRestriction('Vanilla.Approval.Require');
                 if ($ApprovalRequired && !GetValue('Verified', Gdn::Session()->User)) {
                     LogModel::Insert('Pending', 'Discussion', $Fields);
                     return UNAPPROVED;
                 }
                 // Create discussion
                 $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 (GetValue('Announce', $Fields)) {
                         Gdn::Cache()->Remove('Announcements');
开发者ID:bishopb,项目名称:vanilla,代码行数:67,代码来源:class.discussionmodel.php

示例3: Save

 /**
  * Insert or update core data about the comment.
  * 
  * Events: BeforeSaveComment, AfterSaveComment.
  * 
  * @since 2.0.0
  * @access public
  *
  * @param array $FormPostValues Data from the form model.
  * @return int $CommentID
  */
 public function Save($FormPostValues)
 {
     $Session = Gdn::Session();
     // Define the primary key in this model's table.
     $this->DefineSchema();
     // Add & apply any extra validation rules:
     $this->Validation->ApplyRule('Body', 'Required');
     $MaxCommentLength = Gdn::Config('Vanilla.Comment.MaxLength');
     if (is_numeric($MaxCommentLength) && $MaxCommentLength > 0) {
         $this->Validation->SetSchemaProperty('Body', 'Length', $MaxCommentLength);
         $this->Validation->ApplyRule('Body', 'Length');
     }
     // Validate $CommentID and whether this is an insert
     $CommentID = ArrayValue('CommentID', $FormPostValues);
     $CommentID = is_numeric($CommentID) && $CommentID > 0 ? $CommentID : FALSE;
     $Insert = $CommentID === FALSE;
     if ($Insert) {
         $this->AddInsertFields($FormPostValues);
     } else {
         $this->AddUpdateFields($FormPostValues);
     }
     // Prep and fire event
     $this->EventArguments['FormPostValues'] =& $FormPostValues;
     $this->EventArguments['CommentID'] = $CommentID;
     $this->FireEvent('BeforeSaveComment');
     // Validate the form posted values
     if ($this->Validate($FormPostValues, $Insert)) {
         // If the post is new and it validates, check for spam
         if (!$Insert || !$this->CheckForSpam('Comment')) {
             $Fields = $this->Validation->SchemaValidationFields();
             $Fields = RemoveKeyFromArray($Fields, $this->PrimaryKey);
             if ($Insert === FALSE) {
                 // Log the save.
                 LogModel::LogChange('Edit', 'Comment', array_merge($Fields, array('CommentID' => $CommentID)));
                 // Save the new value.
                 $this->SQL->Put($this->Name, $Fields, array('CommentID' => $CommentID));
             } else {
                 // Make sure that the comments get formatted in the method defined by Garden.
                 if (!GetValue('Format', $Fields)) {
                     $Fields['Format'] = Gdn::Config('Garden.InputFormatter', '');
                 }
                 // Check for spam.
                 $Spam = SpamModel::IsSpam('Comment', $Fields);
                 if (!$Spam) {
                     $CommentID = $this->SQL->Insert($this->Name, $Fields);
                     $this->EventArguments['CommentID'] = $CommentID;
                     // IsNewDiscussion is passed when the first comment for new discussions are created.
                     $this->EventArguments['IsNewDiscussion'] = GetValue('IsNewDiscussion', $FormPostValues);
                     $this->FireEvent('AfterSaveComment');
                 } else {
                     return SPAM;
                 }
             }
         }
     }
     // Update discussion's comment count
     $DiscussionID = GetValue('DiscussionID', $FormPostValues);
     $this->UpdateCommentCount($DiscussionID);
     return $CommentID;
 }
开发者ID:Raz0r,项目名称:Garden,代码行数:71,代码来源:class.commentmodel.php

示例4: Save

 /**
  * Inserts or updates the discussion via form values.
  * 
  * Events: BeforeSaveDiscussion, AfterSaveDiscussion.
  *
  * @since 2.0.0
  * @access public
  * 
  * @param array $FormPostValues Data sent from the form model.
  * @return int $DiscussionID Unique ID of the discussion.
  */
 public function Save($FormPostValues)
 {
     $Session = Gdn::Session();
     // Define the primary key in this model's table.
     $this->DefineSchema();
     // Add & apply any extra validation rules:
     $this->Validation->ApplyRule('Body', 'Required');
     $MaxCommentLength = Gdn::Config('Vanilla.Comment.MaxLength');
     if (is_numeric($MaxCommentLength) && $MaxCommentLength > 0) {
         $this->Validation->SetSchemaProperty('Body', 'Length', $MaxCommentLength);
         $this->Validation->ApplyRule('Body', 'Length');
     }
     // Get the DiscussionID from the form so we know if we are inserting or updating.
     $DiscussionID = ArrayValue('DiscussionID', $FormPostValues, '');
     // See if there is a source ID.
     if (array_key_exists('SourceID', $FormPostValues)) {
         $DiscussionID = $this->SQL->GetWhere('Discussion', ArrayTranslate($FormPostValues, array('Source', 'SourceID')))->Value('DiscussionID');
         if ($DiscussionID) {
             $FormPostValues['DiscussionID'] = $DiscussionID;
         }
     }
     $Insert = $DiscussionID == '' ? TRUE : FALSE;
     $this->EventArguments['Insert'] = $Insert;
     if ($Insert) {
         unset($FormPostValues['DiscussionID']);
         // If no categoryid is defined, grab the first available.
         if (ArrayValue('CategoryID', $FormPostValues) === FALSE) {
             $FormPostValues['CategoryID'] = $this->SQL->Get('Category', 'CategoryID', '', 1)->FirstRow()->CategoryID;
         }
         $this->AddInsertFields($FormPostValues);
         // $FormPostValues['LastCommentUserID'] = $Session->UserID;
         $FormPostValues['DateLastComment'] = Gdn_Format::ToDateTime();
     }
     // Add the update fields because this table's default sort is by DateUpdated (see $this->Get()).
     $this->AddUpdateFields($FormPostValues);
     // Set checkbox values to zero if they were unchecked
     if (ArrayValue('Announce', $FormPostValues, '') === FALSE) {
         $FormPostValues['Announce'] = 0;
     }
     if (ArrayValue('Closed', $FormPostValues, '') === FALSE) {
         $FormPostValues['Closed'] = 0;
     }
     if (ArrayValue('Sink', $FormPostValues, '') === FALSE) {
         $FormPostValues['Sink'] = 0;
     }
     //	Prep and fire event
     $this->EventArguments['FormPostValues'] =& $FormPostValues;
     $this->EventArguments['DiscussionID'] = $DiscussionID;
     $this->FireEvent('BeforeSaveDiscussion');
     // Validate the form posted values
     if ($this->Validate($FormPostValues, $Insert)) {
         // If the post is new and it validates, make sure the user isn't spamming
         if (!$Insert || !$this->CheckForSpam('Discussion')) {
             // Get all fields on the form that relate to the schema
             $Fields = $this->Validation->SchemaValidationFields();
             // Get DiscussionID if one was sent
             $DiscussionID = intval(ArrayValue('DiscussionID', $Fields, 0));
             // Remove the primary key from the fields for saving
             $Fields = RemoveKeyFromArray($Fields, 'DiscussionID');
             $Discussion = FALSE;
             $StoredCategoryID = FALSE;
             if ($DiscussionID > 0) {
                 // Updating
                 $Stored = $this->GetID($DiscussionID);
                 // Clear the cache if necessary.
                 if (GetValue('Announce', $Stored) != GetValue('Announce', $Fields)) {
                     $CacheKeys = array('Announcements', 'Announcements_' . GetValue('CategoryID', $Fields));
                     $Announce = GetValue('Announce', $Discussion);
                     $this->SQL->Cache($CacheKeys);
                 }
                 $this->SQL->Put($this->Name, $Fields, array($this->PrimaryKey => $DiscussionID));
                 $Fields['DiscussionID'] = $DiscussionID;
                 LogModel::LogChange('Edit', 'Discussion', (array) $Fields, (array) $Stored);
                 if ($Stored->CategoryID != $Fields['CategoryID']) {
                     $StoredCategoryID = $Stored->CategoryID;
                 }
             } else {
                 // Inserting.
                 if (!GetValue('Format', $Fields)) {
                     $Fields['Format'] = Gdn::Config('Garden.InputFormatter', '');
                 }
                 // Check for spam.
                 $Spam = SpamModel::IsSpam('Discussion', $Fields);
                 // Clear the cache if necessary.
                 if (GetValue('Announce', $Fields)) {
                     $CacheKeys = array('Announcements', 'Announcements_' . GetValue('CategoryID', $Fields));
                     $Announce = GetValue('Announce', $Discussion);
                     $this->SQL->Cache($CacheKeys);
                 }
//.........这里部分代码省略.........
开发者ID:ru4,项目名称:arabbnota,代码行数:101,代码来源:class.discussionmodel.php


注:本文中的LogModel::LogChange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。