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


PHP CategoryModel::getWhere方法代码示例

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


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

示例1: deleteUserData

 /**
  * Delete all of the Vanilla related information for a specific user.
  *
  * @since 2.1
  *
  * @param int $UserID The ID of the user to delete.
  * @param array $Options An array of options:
  *  - DeleteMethod: One of delete, wipe, or NULL
  */
 public function deleteUserData($UserID, $Options = array(), &$Data = null)
 {
     $SQL = Gdn::sql();
     // Remove discussion watch records and drafts.
     $SQL->delete('UserDiscussion', array('UserID' => $UserID));
     Gdn::userModel()->GetDelete('Draft', array('InsertUserID' => $UserID), $Data);
     // Comment deletion depends on method selected
     $DeleteMethod = val('DeleteMethod', $Options, 'delete');
     if ($DeleteMethod == 'delete') {
         // Clear out the last posts to the categories.
         $SQL->update('Category c')->join('Discussion d', 'd.DiscussionID = c.LastDiscussionID')->where('d.InsertUserID', $UserID)->set('c.LastDiscussionID', null)->set('c.LastCommentID', null)->put();
         $SQL->update('Category c')->join('Comment d', 'd.CommentID = c.LastCommentID')->where('d.InsertUserID', $UserID)->set('c.LastDiscussionID', null)->set('c.LastCommentID', null)->put();
         // Grab all of the discussions that the user has engaged in.
         $DiscussionIDs = $SQL->select('DiscussionID')->from('Comment')->where('InsertUserID', $UserID)->groupBy('DiscussionID')->get()->resultArray();
         $DiscussionIDs = consolidateArrayValuesByKey($DiscussionIDs, 'DiscussionID');
         Gdn::userModel()->GetDelete('Comment', array('InsertUserID' => $UserID), $Data);
         // Update the comment counts.
         $CommentCounts = $SQL->select('DiscussionID')->select('CommentID', 'count', 'CountComments')->select('CommentID', 'max', 'LastCommentID')->whereIn('DiscussionID', $DiscussionIDs)->groupBy('DiscussionID')->get('Comment')->resultArray();
         foreach ($CommentCounts as $Row) {
             $SQL->put('Discussion', array('CountComments' => $Row['CountComments'] + 1, 'LastCommentID' => $Row['LastCommentID']), array('DiscussionID' => $Row['DiscussionID']));
         }
         // Update the last user IDs.
         $SQL->update('Discussion d')->join('Comment c', 'd.LastCommentID = c.CommentID', 'left')->set('d.LastCommentUserID', 'c.InsertUserID', false, false)->set('d.DateLastComment', 'c.DateInserted', false, false)->whereIn('d.DiscussionID', $DiscussionIDs)->put();
         // Update the last posts.
         $Discussions = $SQL->whereIn('DiscussionID', $DiscussionIDs)->where('LastCommentUserID', $UserID)->get('Discussion');
         // Delete the user's dicussions
         Gdn::userModel()->GetDelete('Discussion', array('InsertUserID' => $UserID), $Data);
         // Update the appropriat recent posts in the categories.
         $CategoryModel = new CategoryModel();
         $Categories = $CategoryModel->getWhere(array('LastDiscussionID' => null))->resultArray();
         foreach ($Categories as $Category) {
             $CategoryModel->SetRecentPost($Category['CategoryID']);
         }
     } elseif ($DeleteMethod == 'wipe') {
         // Erase the user's dicussions
         $SQL->update('Discussion')->set('Body', t('The user and all related content has been deleted.'))->set('Format', 'Deleted')->where('InsertUserID', $UserID)->put();
         $SQL->update('Comment')->set('Body', t('The user and all related content has been deleted.'))->set('Format', 'Deleted')->where('InsertUserID', $UserID)->put();
     } else {
         // Leave comments
     }
     // Remove the user's profile information related to this application
     $SQL->update('User')->set(array('CountDiscussions' => 0, 'CountUnreadDiscussions' => 0, 'CountComments' => 0, 'CountDrafts' => 0, 'CountBookmarks' => 0))->where('UserID', $UserID)->put();
 }
开发者ID:dimassrio,项目名称:vanilla,代码行数:52,代码来源:class.hooks.php

示例2: deleteCategory

 /**
  * Deleting a category.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $CategoryID Unique ID of the category to be deleted.
  */
 public function deleteCategory($CategoryID = false)
 {
     // Check permission
     $this->permission(['Garden.Community.Manage', 'Garden.Settings.Manage'], false);
     // Set up head
     $this->addJsFile('manage-categories.js');
     $this->title(t('Delete Category'));
     $this->setHighlightRoute('vanilla/settings/categories');
     // Get category data
     $this->Category = $this->CategoryModel->getID($CategoryID);
     if (!$this->Category) {
         $this->Form->addError('The specified category could not be found.');
     } else {
         // Make sure the form knows which item we are deleting.
         $this->Form->addHidden('CategoryID', $CategoryID);
         // Get a list of categories other than this one that can act as a replacement
         $this->OtherCategories = $this->CategoryModel->getWhere(array('CategoryID <>' => $CategoryID, 'AllowDiscussions' => $this->Category->AllowDiscussions, 'CategoryID >' => 0), 'Sort');
         if (!$this->Form->authenticatedPostBack()) {
             $this->Form->setFormValue('DeleteDiscussions', '1');
             // Checked by default
         } else {
             $ReplacementCategoryID = $this->Form->getValue('ReplacementCategoryID');
             $ReplacementCategory = $this->CategoryModel->getID($ReplacementCategoryID);
             // Error if:
             // 1. The category being deleted is the last remaining category that
             // allows discussions.
             if ($this->Category->AllowDiscussions == '1' && $this->OtherCategories->numRows() == 0) {
                 $this->Form->addError('You cannot remove the only remaining category that allows discussions');
             }
             /*
             // 2. The category being deleted allows discussions, and it contains
             // discussions, and there is no replacement category specified.
             if ($this->Form->errorCount() == 0
                && $this->Category->AllowDiscussions == '1'
                && $this->Category->CountDiscussions > 0
                && ($ReplacementCategory == FALSE || $ReplacementCategory->AllowDiscussions != '1'))
                $this->Form->addError('You must select a replacement category in order to remove this category.');
             */
             // 3. The category being deleted does not allow discussions, and it
             // does contain other categories, and there are replacement parent
             // categories available, and one is not selected.
             /*
             if ($this->Category->AllowDiscussions == '0'
                && $this->OtherCategories->numRows() > 0
                && !$ReplacementCategory) {
                if ($this->CategoryModel->getWhere(array('ParentCategoryID' => $CategoryID))->numRows() > 0)
                   $this->Form->addError('You must select a replacement category in order to remove this category.');
             }
             */
             if ($this->Form->errorCount() == 0) {
                 // Go ahead and delete the category
                 try {
                     $this->CategoryModel->delete($this->Category, $this->Form->getValue('ReplacementCategoryID'));
                 } catch (Exception $ex) {
                     $this->Form->addError($ex);
                 }
                 if ($this->Form->errorCount() == 0) {
                     $this->RedirectUrl = url('vanilla/settings/categories');
                     $this->informMessage(t('Deleting category...'));
                 }
             }
         }
     }
     // Render default view
     $this->render();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:74,代码来源:class.vanillasettingscontroller.php


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