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


PHP DiscussionModel::UpdateDiscussionCount方法代码示例

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


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

示例1: Advanced

	/**
    * Advanced settings.
    *
    * Allows setting configuration values via form elements.
    * 
    * @since 2.0.0
    * @access public
    */
	public function Advanced() {
	   // Check permission
      $this->Permission('Vanilla.Settings.Manage');
		
		// Load up config options we'll be setting
		$Validation = new Gdn_Validation();
      $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
      $ConfigurationModel->SetField(array(
         'Vanilla.Discussions.PerPage',
         'Vanilla.Comments.AutoRefresh',
         'Vanilla.Comments.PerPage',
         'Vanilla.Archive.Date',
			'Vanilla.Archive.Exclude',
			'Garden.EditContentTimeout'
      ));
      
      // Set the model on the form.
      $this->Form->SetModel($ConfigurationModel);
      
      // If seeing the form for the first time...
      if ($this->Form->AuthenticatedPostBack() === FALSE) {
         // Apply the config settings to the form.
         $this->Form->SetData($ConfigurationModel->Data);
		} else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Required');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Integer');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.AutoRefresh', 'Integer');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Required');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Integer');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Archive.Date', 'Date');
			$ConfigurationModel->Validation->ApplyRule('Garden.EditContentTimeout', 'Integer');
			
			// Grab old config values to check for an update.
			$ArchiveDateBak = Gdn::Config('Vanilla.Archive.Date');
			$ArchiveExcludeBak = (bool)Gdn::Config('Vanilla.Archive.Exclude');
			
			// Save new settings
			$Saved = $this->Form->Save();
			if($Saved) {
				$ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
				$ArchiveExclude = (bool)Gdn::Config('Vanilla.Archive.Exclude');
				
				if($ArchiveExclude != $ArchiveExcludeBak || ($ArchiveExclude && $ArchiveDate != $ArchiveDateBak)) {
					$DiscussionModel = new DiscussionModel();
					$DiscussionModel->UpdateDiscussionCount('All');
				}
            $this->InformMessage(T("Your changes have been saved."));
			}
		}
		
      $this->AddSideMenu('vanilla/settings/advanced');
      $this->AddJsFile('settings.js');
      $this->Title(T('Advanced Forum Settings'));
		
		// Render default view (settings/advanced.php)
		$this->Render();
	}
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:66,代码来源:class.settingscontroller.php

示例2: CategoriesController_RefreshCounts_Create

 public function CategoriesController_RefreshCounts_Create($Sender)
 {
     $Sender->Permission('Vanilla.Categories.Manage');
     $DiscussionModel = new DiscussionModel();
     $CategoryModel = $Sender->CategoryModel;
     $Categories = $CategoryModel->GetAll();
     foreach ($Categories as $Category) {
         $CategoryID = $Category->CategoryID;
         $DiscussionModel->UpdateDiscussionCount($CategoryID);
     }
     // stash the inform message for later
     Gdn::Session()->Stash('RefreshCountsMessage', T('RefreshCounts.CatComplete'));
     Redirect('/vanilla/settings/managecategories');
 }
开发者ID:oMadMartigaNo,项目名称:readjust-forum,代码行数:14,代码来源:class.refreshcounts.plugin.php

示例3: DiscussionController_Flag_Create

 /**
  * Handle flagging process in a discussion.
  */
 public function DiscussionController_Flag_Create($Sender)
 {
     if (!C('Plugins.Flagging.Enabled')) {
         return;
     }
     // Signed in users only.
     if (!($UserID = Gdn::Session()->UserID)) {
         return;
     }
     $UserName = Gdn::Session()->User->Name;
     $Arguments = $Sender->RequestArgs;
     if (sizeof($Arguments) != 5) {
         return;
     }
     list($Context, $ElementID, $ElementAuthorID, $ElementAuthor, $EncodedURL) = $Arguments;
     $URL = base64_decode(str_replace('-', '=', $EncodedURL));
     $Sender->SetData('Plugin.Flagging.Data', array('Context' => $Context, 'ElementID' => $ElementID, 'ElementAuthorID' => $ElementAuthorID, 'ElementAuthor' => $ElementAuthor, 'URL' => $URL, 'UserID' => $UserID, 'UserName' => $UserName));
     if ($Sender->Form->AuthenticatedPostBack()) {
         $SQL = Gdn::SQL();
         $Comment = $Sender->Form->GetValue('Plugin.Flagging.Reason');
         $Sender->SetData('Plugin.Flagging.Reason', $Comment);
         $CreateDiscussion = C('Plugins.Flagging.UseDiscussions');
         if ($CreateDiscussion) {
             // Category
             $CategoryID = C('Plugins.Flagging.CategoryID');
             // New discussion name
             if ($Context == 'comment') {
                 $Result = $SQL->Select('d.Name')->Select('c.Body')->From('Comment c')->Join('Discussion d', 'd.DiscussionID = c.DiscussionID', 'left')->Where('c.CommentID', $ElementID)->Get()->FirstRow();
             } elseif ($Context == 'discussion') {
                 $DiscussionModel = new DiscussionModel();
                 $Result = $DiscussionModel->GetID($ElementID);
             }
             $DiscussionName = GetValue('Name', $Result);
             $PrefixedDiscussionName = T('FlagPrefix', 'FLAG: ') . $DiscussionName;
             // Prep data for the template
             $Sender->SetData('Plugin.Flagging.Report', array('DiscussionName' => $DiscussionName, 'FlaggedContent' => GetValue('Body', $Result)));
             // Assume no discussion exists
             $this->DiscussionID = NULL;
             // Get discussion ID if already flagged
             $FlagResult = Gdn::SQL()->Select('DiscussionID')->From('Flag fl')->Where('ForeignType', $Context)->Where('ForeignID', $ElementID)->Get()->FirstRow();
             if ($FlagResult) {
                 // New comment in existing discussion
                 $DiscussionID = $FlagResult->DiscussionID;
                 $ReportBody = $Sender->FetchView($this->GetView('reportcomment.php'));
                 $SQL->Insert('Comment', array('DiscussionID' => $DiscussionID, 'InsertUserID' => $UserID, 'Body' => $ReportBody, 'Format' => 'Html', 'DateInserted' => date('Y-m-d H:i:s')));
                 $CommentModel = new CommentModel();
                 $CommentModel->UpdateCommentCount($DiscussionID);
             } else {
                 // New discussion body
                 $ReportBody = $Sender->FetchView($this->GetView('report.php'));
                 $DiscussionID = $SQL->Insert('Discussion', array('InsertUserID' => $UserID, 'UpdateUserID' => $UserID, 'CategoryID' => $CategoryID, 'Name' => $PrefixedDiscussionName, 'Body' => $ReportBody, 'Format' => 'Html', 'CountComments' => 1, 'DateInserted' => date('Y-m-d H:i:s'), 'DateUpdated' => date('Y-m-d H:i:s'), 'DateLastComment' => date('Y-m-d H:i:s')));
                 // Update discussion count
                 $DiscussionModel = new DiscussionModel();
                 $DiscussionModel->UpdateDiscussionCount($CategoryID);
             }
         }
         try {
             // Insert the flag
             $SQL->Insert('Flag', array('DiscussionID' => $DiscussionID, 'InsertUserID' => $UserID, 'InsertName' => $UserName, 'AuthorID' => $ElementAuthorID, 'AuthorName' => $ElementAuthor, 'ForeignURL' => $URL, 'ForeignID' => $ElementID, 'ForeignType' => $Context, 'Comment' => $Comment, 'DateInserted' => date('Y-m-d H:i:s')));
         } catch (Exception $e) {
         }
         // Notify users with permission who've chosen to be notified
         if (!$FlagResult) {
             // Only send if this is first time it's being flagged.
             $Sender->SetData('Plugin.Flagging.DiscussionID', $DiscussionID);
             $Subject = isset($PrefixedDiscussionName) ? $PrefixedDiscussionName : T('FlagDiscussion', 'A discussion was flagged');
             $EmailBody = $Sender->FetchView($this->GetView('reportemail.php'));
             $NotifyUsers = C('Plugins.Flagging.NotifyUsers', array());
             // Send emails
             $UserModel = new UserModel();
             foreach ($NotifyUsers as $UserID) {
                 $User = $UserModel->GetID($UserID);
                 $Email = new Gdn_Email();
                 $Email->To($User->Email)->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $Subject))->Message($EmailBody)->Send();
             }
         }
         $Sender->InformMessage(T('FlagSent', "Your complaint has been registered."));
     }
     $Sender->Render($this->GetView('flag.php'));
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:83,代码来源:class.flagging.plugin.php

示例4: DiscussionModel

 * @copyright 2009-2016 Vanilla Forums Inc.
 * @license http://www.opensource.org/licenses/gpl-2.0.php GNU GPL v2
 * @since 2.0
 * @package Vanilla
 */
$SQL = Gdn::database()->sql();
// Only do this once, ever.
$Row = $SQL->get('Discussion', '', 'asc', 1)->firstRow(DATASET_TYPE_ARRAY);
if ($Row) {
    return;
}
$DiscussionModel = new DiscussionModel();
// Prep default content
$DiscussionTitle = "BAM! You’ve got a sweet forum";
$DiscussionBody = "There&rsquo;s nothing sweeter than a fresh new forum, ready to welcome your community. A Vanilla Forum has all the bits and pieces you need to build an awesome discussion platform customized to your needs. Here&rsquo;s a few tips:\n<ul>\n   <li>Use the <a href=\"/dashboard/settings/gettingstarted\">Getting Started</a> list in the Dashboard to configure your site.</li>\n   <li>Don&rsquo;t use too many categories. We recommend 3-8. Keep it simple!</li>\n   <li>&ldquo;Announce&rdquo; a discussion (click the gear) to stick to the top of the list, and &ldquo;Close&rdquo; it to stop further comments.</li>\n   <li>Use &ldquo;Sink&rdquo; to take attention away from a discussion. New comments will no longer bring it back to the top of the list.</li>\n   <li>Bookmark a discussion (click the star) to get notifications for new comments. You can edit notification settings from your profile.</li>\n</ul>\nGo ahead and edit or delete this discussion, then spread the word to get this place cooking. Cheers!";
$CommentBody = "This is the first comment on your site and it&rsquo;s an important one.\n\nDon&rsquo;t see your must-have feature? We keep Vanilla nice and simple by default. Use <b>addons</b> to get the special sauce your community needs.\n\nNot sure which addons to enable? Our favorites are Button Bar and Tagging. They&rsquo;re almost always a great start.";
$WallBody = "Ping! An activity post is a public way to talk at someone. When you update your status here, it posts it on your activity feed.";
// Prep content meta data
$SystemUserID = Gdn::userModel()->GetSystemUserID();
$TargetUserID = Gdn::session()->UserID;
$Now = Gdn_Format::toDateTime();
$CategoryID = val('CategoryID', CategoryModel::DefaultCategory());
// Get wall post type ID
$WallCommentTypeID = $SQL->getWhere('ActivityType', array('Name' => 'WallPost'))->value('ActivityTypeID');
// Insert first discussion & comment
$DiscussionID = $SQL->Options('Ignore', true)->insert('Discussion', array('Name' => t('StubDiscussionTitle', $DiscussionTitle), 'Body' => t('StubDiscussionBody', $DiscussionBody), 'Format' => 'Html', 'CategoryID' => $CategoryID, 'ForeignID' => 'stub', 'InsertUserID' => $SystemUserID, 'DateInserted' => $Now, 'DateLastComment' => $Now, 'LastCommentUserID' => $SystemUserID, 'CountComments' => 1));
$CommentID = $SQL->insert('Comment', array('DiscussionID' => $DiscussionID, 'Body' => t('StubCommentBody', $CommentBody), 'Format' => 'Html', 'InsertUserID' => $SystemUserID, 'DateInserted' => $Now));
$SQL->update('Discussion')->set('LastCommentID', $CommentID)->where('DiscussionID', $DiscussionID)->put();
$DiscussionModel->UpdateDiscussionCount($CategoryID);
// Insert first wall post
$SQL->insert('Activity', array('Story' => t('StubWallBody', $WallBody), 'Format' => 'Html', 'HeadlineFormat' => '{RegardingUserID,you} &rarr; {ActivityUserID,you}', 'NotifyUserID' => -1, 'ActivityUserID' => $TargetUserID, 'RegardingUserID' => $SystemUserID, 'ActivityTypeID' => $WallCommentTypeID, 'InsertUserID' => $SystemUserID, 'DateInserted' => $Now, 'DateUpdated' => $Now));
开发者ID:sitexa,项目名称:vanilla,代码行数:31,代码来源:stub.php

示例5: Comment


//.........这里部分代码省略.........
             $vanilla_category_id = C('Vanilla.Embed.DefaultCategoryID', 0);
             if ($vanilla_category_id <= 0) {
                 // No default category defined, so grab the first non-root category and use that.
                 $vanilla_category_id = $this->DiscussionModel->SQL->Select('CategoryID')->From('Category')->Where('CategoryID >', 0)->Get()->FirstRow()->CategoryID;
                 // No categories in the db? default to 0
                 if (!$vanilla_category_id) {
                     $vanilla_category_id = 0;
                 }
             }
         } else {
             $vanilla_category_id = $Category['CategoryID'];
         }
         $EmbedUserID = C('Garden.Embed.UserID');
         if ($EmbedUserID) {
             $EmbedUser = Gdn::UserModel()->GetID($EmbedUserID);
         }
         if (!$EmbedUserID || !$EmbedUser) {
             $EmbedUserID = Gdn::UserModel()->GetSystemUserID();
         }
         $EmbeddedDiscussionData = array('InsertUserID' => $EmbedUserID, 'DateInserted' => Gdn_Format::ToDateTime(), 'DateUpdated' => Gdn_Format::ToDateTime(), 'CategoryID' => $vanilla_category_id, 'ForeignID' => $vanilla_identifier, 'Type' => $vanilla_type, 'Name' => $Title, 'Body' => $Body, 'Format' => 'Html', 'Attributes' => serialize($Attributes));
         $this->EventArguments['Discussion'] = $EmbeddedDiscussionData;
         $this->FireEvent('BeforeEmbedDiscussion');
         $DiscussionID = $this->DiscussionModel->SQL->Insert('Discussion', $EmbeddedDiscussionData);
         $ValidationResults = $this->DiscussionModel->ValidationResults();
         if (count($ValidationResults) == 0 && $DiscussionID > 0) {
             $this->Form->AddHidden('DiscussionID', $DiscussionID);
             // Put this in the form so reposts won't cause new discussions.
             $this->Form->SetFormValue('DiscussionID', $DiscussionID);
             // Put this in the form values so it is used when saving comments.
             $this->SetJson('DiscussionID', $DiscussionID);
             $this->Discussion = $Discussion = $this->DiscussionModel->GetID($DiscussionID, DATASET_TYPE_OBJECT, array('Slave' => FALSE));
             // Update the category discussion count
             if ($vanilla_category_id > 0) {
                 $this->DiscussionModel->UpdateDiscussionCount($vanilla_category_id, $DiscussionID);
             }
         }
     }
     // If no discussion was found, error out
     if (!$Discussion) {
         $this->Form->AddError(T('Failed to find discussion for commenting.'));
     }
     $PermissionCategoryID = GetValue('PermissionCategoryID', $Discussion);
     // Setup head
     $this->AddJsFile('jquery.autosize.min.js');
     $this->AddJsFile('post.js');
     $this->AddJsFile('autosave.js');
     // Setup comment model, $CommentID, $DraftID
     $Session = Gdn::Session();
     $CommentID = isset($this->Comment) && property_exists($this->Comment, 'CommentID') ? $this->Comment->CommentID : '';
     $DraftID = isset($this->Comment) && property_exists($this->Comment, 'DraftID') ? $this->Comment->DraftID : '';
     $this->EventArguments['CommentID'] = $CommentID;
     $this->EventArguments['DraftID'] = $DraftID;
     // Determine whether we are editing
     $Editing = $CommentID > 0 || $DraftID > 0;
     $this->EventArguments['Editing'] = $Editing;
     // If closed, cancel & go to discussion
     if ($Discussion && $Discussion->Closed == 1 && !$Editing && !$Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $PermissionCategoryID)) {
         Redirect(DiscussionUrl($Discussion));
     }
     // Add hidden IDs to form
     $this->Form->AddHidden('DiscussionID', $DiscussionID);
     $this->Form->AddHidden('CommentID', $CommentID);
     $this->Form->AddHidden('DraftID', $DraftID, TRUE);
     // Check permissions
     if ($Discussion && $Editing) {
         // Permisssion to edit
开发者ID:embo-hd,项目名称:vanilla,代码行数:67,代码来源:class.postcontroller.php

示例6: archive

 public function archive()
 {
     // Check permission
     $this->permission('Garden.Settings.Manage');
     // Load up config options we'll be setting
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->setField(array('Vanilla.Archive.Date', 'Vanilla.Archive.Exclude'));
     // Set the model on the form.
     $this->Form->setModel($ConfigurationModel);
     // If seeing the form for the first time...
     if ($this->Form->authenticatedPostBack() === false) {
         $this->Form->setData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->applyRule('Vanilla.Archive.Date', 'Date');
         // Grab old config values to check for an update.
         $ArchiveDateBak = Gdn::config('Vanilla.Archive.Date');
         $ArchiveExcludeBak = (bool) Gdn::config('Vanilla.Archive.Exclude');
         // Save new settings
         $Saved = $this->Form->save();
         if ($Saved !== false) {
             $ArchiveDate = Gdn::config('Vanilla.Archive.Date');
             $ArchiveExclude = (bool) Gdn::config('Vanilla.Archive.Exclude');
             if ($ArchiveExclude != $ArchiveExcludeBak || $ArchiveExclude && $ArchiveDate != $ArchiveDateBak) {
                 $DiscussionModel = new DiscussionModel();
                 $DiscussionModel->UpdateDiscussionCount('All');
             }
             $this->informMessage(t("Your changes have been saved."));
         }
     }
     $this->setHighlightRoute('vanilla/settings/archive');
     $this->title(t('Archive Discussions'));
     // Render default view (settings/archive.php)
     $this->render();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:36,代码来源:class.vanillasettingscontroller.php

示例7: Commit

 public function Commit()
 {
     if (is_null($this->Type)) {
         throw new Exception(T("Adding a Regarding event requires a type."));
     }
     if (is_null($this->ForeignType)) {
         throw new Exception(T("Adding a Regarding event requires a foreign association type."));
     }
     if (is_null($this->ForeignID)) {
         throw new Exception(T("Adding a Regarding event requires a foreign association id."));
     }
     if (is_null($this->Comment)) {
         throw new Exception(T("Adding a Regarding event requires a comment."));
     }
     if (is_null($this->UserID)) {
         $this->UserID = Gdn::Session()->UserID;
     }
     $RegardingModel = new RegardingModel();
     $CollapseMode = C('Garden.Regarding.AutoCollapse', TRUE);
     $Collapse = FALSE;
     if ($CollapseMode) {
         // Check for an existing report of this type
         $ExistingRegardingEntity = $RegardingModel->GetRelated($this->Type, $this->ForeignType, $this->ForeignID);
         if ($ExistingRegardingEntity) {
             $Collapse = TRUE;
             $RegardingID = GetValue('RegardingID', $ExistingRegardingEntity);
         }
     }
     if (!$Collapse) {
         // Create a new Regarding entry
         $RegardingPreSend = array('Type' => $this->Type, 'ForeignType' => $this->ForeignType, 'ForeignID' => $this->ForeignID, 'InsertUserID' => $this->UserID, 'DateInserted' => date('Y-m-d H:i:s'), 'ParentType' => $this->ParentType, 'ParentID' => $this->ParentID, 'ForeignURL' => $this->ForeignURL, 'Comment' => $this->Comment, 'OriginalContent' => $this->OriginalContent, 'Reports' => 1);
         $RegardingID = $RegardingModel->Save($RegardingPreSend);
         if (!$RegardingID) {
             return FALSE;
         }
     }
     // Handle collaborations
     // Don't error on foreach
     if (!is_array($this->CollaborativeActions)) {
         $this->CollaborativeActions = array();
     }
     foreach ($this->CollaborativeActions as $Action) {
         $ActionType = GetValue('Type', $Action);
         switch ($ActionType) {
             case 'discussion':
                 $DiscussionModel = new DiscussionModel();
                 if ($Collapse) {
                     $Discussion = Gdn::SQL()->Select('*')->From('Discussion')->Where(array('RegardingID' => $RegardingID))->Get()->FirstRow(DATASET_TYPE_ARRAY);
                 }
                 if (!$Collapse || !$Discussion) {
                     $CategoryID = GetValue('Parameters', $Action);
                     // Make a new discussion
                     $DiscussionID = $DiscussionModel->Save(array('Name' => $this->CollaborativeTitle, 'CategoryID' => $CategoryID, 'Body' => $this->OriginalContent, 'InsertUserID' => GetValue('InsertUserID', $this->SourceElement), 'Announce' => 0, 'Close' => 0, 'RegardingID' => $RegardingID));
                     if (!$DiscussionID) {
                         throw new Gdn_UserException($DiscussionModel->Validation->ResultsText());
                     }
                     $DiscussionModel->UpdateDiscussionCount($CategoryID);
                 } else {
                     // Add a comment to the existing discussion.
                     $CommentModel = new CommentModel();
                     $CommentID = $CommentModel->Save(array('DiscussionID' => GetValue('DiscussionID', $Discussion), 'Body' => $this->Comment, 'InsertUserID' => $this->UserID));
                     $CommentModel->Save2($CommentID, TRUE);
                 }
                 break;
             case 'conversation':
                 $ConversationModel = new ConversationModel();
                 $ConversationMessageModel = new ConversationMessageModel();
                 $Users = GetValue('Parameters', $Action);
                 $UserList = explode(',', $Users);
                 if (!sizeof($UserList)) {
                     throw new Exception(sprintf(T("The userlist provided for collaboration on '%s:%s' is invalid.", $this->Type, $this->ForeignType)));
                 }
                 $ConversationID = $ConversationModel->Save(array('To' => 'Admins', 'Body' => $this->CollaborativeTitle, 'RecipientUserID' => $UserList, 'RegardingID' => $RegardingID), $ConversationMessageModel);
                 break;
         }
     }
     return TRUE;
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:78,代码来源:class.regardingentity.php


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