本文整理汇总了PHP中DiscussionModel::GetIn方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussionModel::GetIn方法的具体用法?PHP DiscussionModel::GetIn怎么用?PHP DiscussionModel::GetIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussionModel
的用法示例。
在下文中一共展示了DiscussionModel::GetIn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ModerationController_MergeDiscussions_Create
/**
* Add a method to the ModerationController to handle merging discussions.
*/
public function ModerationController_MergeDiscussions_Create($Sender) {
$Session = Gdn::Session();
$Sender->Form = new Gdn_Form();
$Sender->Title(T('Merge Discussions'));
$DiscussionModel = new DiscussionModel();
$CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
if (!is_array($CheckedDiscussions))
$CheckedDiscussions = array();
$DiscussionIDs = $CheckedDiscussions;
$Sender->SetData('DiscussionIDs', $DiscussionIDs);
$CountCheckedDiscussions = count($DiscussionIDs);
$Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
$DiscussionData = $DiscussionModel->GetIn($DiscussionIDs);
$Sender->SetData('DiscussionData', $DiscussionData);
// Perform the merge
if ($Sender->Form->AuthenticatedPostBack()) {
// Create a new discussion record
$MergeDiscussion = FALSE;
$MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
foreach ($DiscussionData->Result() as $Discussion) {
if ($Discussion->DiscussionID == $MergeDiscussionID) {
$MergeDiscussion = $Discussion;
break;
}
}
if ($MergeDiscussion) {
// Verify that the user has permission to perform the merge
$Sender->Permission('Vanilla.Discussion.Edit', TRUE, 'Category', $MergeDiscussion->CategoryID);
// Assign the comments to the new discussion record
$DiscussionModel->SQL
->Update('Comment')
->Set('DiscussionID', $MergeDiscussionID)
->WhereIn('DiscussionID', $DiscussionIDs)
->Put();
$CommentModel = new CommentModel();
foreach ($DiscussionIDs as $DiscussionID) {
// Add a new comment to each empty discussion
if ($DiscussionID != $MergeDiscussionID) {
// Add a comment to each one explaining the merge
$DiscussionAnchor = Anchor(
Gdn_Format::Text($MergeDiscussion->Name),
'discussion/'.$MergeDiscussionID.'/'.Gdn_Format::Url($MergeDiscussion->Name)
);
$CommentModel->Save(array(
'DiscussionID' => $DiscussionID,
'Body' => sprintf(T('This discussion was merged into %s'), $DiscussionAnchor)
));
// Close non-merge discussions
$CommentModel->SQL->Update('Discussion')->Set('Closed', '1')->Where('DiscussionID', $DiscussionID)->Put();
}
// Update counts on all affected discussions
$CommentModel->UpdateCommentCount($DiscussionID);
$CommentModel->UpdateUserCommentCounts($DiscussionID);
}
// Clear selections
Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
ModerationController::InformCheckedDiscussions($Sender);
$Sender->RedirectUrl = Url('discussion/'.$MergeDiscussionID.'/'.Gdn_Format::Url($MergeDiscussion->Name));
}
}
$Sender->Render($this->GetView('mergediscussions.php'));
}