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


PHP DiscussionModel::GetIn方法代码示例

本文整理汇总了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'));
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:74,代码来源:class.splitmerge.plugin.php


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