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


PHP DiscussionModel::CategoryPermissions方法代码示例

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


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

示例1: Get

 public function Get($Begin, $End, $Offset = '0', $Limit = '')
 {
     // Validate parameters, set today as default
     $BeginDate = strtotime($Begin);
     if ($BeginDate <= 0) {
         $BeginDate = date('Y-m-d');
     } else {
         $BeginDate = date('Y-m-d', $BeginDate);
     }
     $EndDate = strtotime($End);
     if ($EndDate <= 0) {
         $EndDate = date('Y-m-d');
     } else {
         $EndDate = date('Y-m-d', $EndDate);
     }
     if (!is_numeric($Offset)) {
         $Offset = 0;
     }
     if (!is_numeric($Limit)) {
         $Limit = '';
     }
     $Sql = GDN::SQL();
     $Sql->Select('d.Name, d.Body, d.Format')->Select('d.InsertUserID', '', 'UserID')->Select('DAY FROM d.EventCalendarDate', 'EXTRACT', 'EventCalendarDay')->From('Discussion d')->Where('d.EventCalendarDate >=', $BeginDate)->Where('d.EventCalendarDate <=', $EndDate)->OrderBy('d.EventCalendarDate')->Limit($Limit, $Offset);
     // add permission restrictions if necessary
     $Perms = DiscussionModel::CategoryPermissions();
     if ($Perms !== TRUE) {
         $Sql->WhereIn('d.CategoryID', $Perms);
     }
     // return $Sql->GetSelect();
     return $Sql->Get()->ResultArray();
 }
开发者ID:shumoo,项目名称:EventCalendar,代码行数:31,代码来源:class.eventcalendarmodel.php

示例2: GetData

   public function GetData($Limit = 10) {
      $this->Data = FALSE;
      if (Gdn::Session()->IsValid() && C('Vanilla.Modules.ShowBookmarkedModule', TRUE)) {
         $BookmarkIDs = Gdn::SQL()
            ->Select('DiscussionID')
            ->From('UserDiscussion')
            ->Where('UserID', Gdn::Session()->UserID)
            ->Where('Bookmarked', 1)
            ->Get()->ResultArray();
         $BookmarkIDs = ConsolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID');

         if (count($BookmarkIDs)) {
            $DiscussionModel = new DiscussionModel();
            DiscussionModel::CategoryPermissions();

            $DiscussionModel->SQL->WhereIn('d.DiscussionID', $BookmarkIDs);
            
            $this->Data = $DiscussionModel->Get(
               0,
               $Limit
            );
         } else {
            $this->Data = FALSE;
         }
      }
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:26,代码来源:class.bookmarkedmodule.php

示例3: getData

 public function getData()
 {
     if (Gdn::session()->isValid()) {
         $BookmarkIDs = Gdn::sql()->select('DiscussionID')->from('UserDiscussion')->where('UserID', Gdn::session()->UserID)->where('Bookmarked', 1)->get()->resultArray();
         $BookmarkIDs = consolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID');
         if (count($BookmarkIDs)) {
             $DiscussionModel = new DiscussionModel();
             DiscussionModel::CategoryPermissions();
             $DiscussionModel->SQL->whereIn('d.DiscussionID', $BookmarkIDs);
             $Bookmarks = $DiscussionModel->get(0, $this->Limit, array('w.Bookmarked' => '1'));
             $this->setData('Bookmarks', $Bookmarks);
         } else {
             $this->setData('Bookmarks', new Gdn_DataSet());
         }
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:16,代码来源:class.bookmarkedmodule.php

示例4: getByUser2

 /**
  *
  * Get comments for a user. This is an optimized version of CommentModel->GetByUser().
  *
  * @since 2.1
  * @access public
  *
  * @param int $UserID Which user to get comments for.
  * @param int $Limit Max number to get.
  * @param int $Offset Number to skip.
  * @param int $LastCommentID A hint for quicker paging.
  * @return Gdn_DataSet SQL results.
  */
 public function getByUser2($UserID, $Limit, $Offset, $LastCommentID = false)
 {
     $Perms = DiscussionModel::CategoryPermissions();
     if (is_array($Perms) && empty($Perms)) {
         return new Gdn_DataSet(array());
     }
     // The point of this query is to select from one comment table, but filter and sort on another.
     // This puts the paging into an index scan rather than a table scan.
     $this->SQL->select('c2.*')->select('d.Name', '', 'DiscussionName')->select('d.CategoryID')->from('Comment c')->join('Comment c2', 'c.CommentID = c2.CommentID')->join('Discussion d', 'c2.DiscussionID = d.DiscussionID')->where('c.InsertUserID', $UserID)->orderBy('c.CommentID', 'desc');
     if ($LastCommentID) {
         // The last comment id from the last page was given and can be used as a hint to speed up the query.
         $this->SQL->where('c.CommentID <', $LastCommentID)->limit($Limit);
     } else {
         $this->SQL->limit($Limit, $Offset);
     }
     $Data = $this->SQL->get();
     $Result =& $Data->result();
     $this->LastCommentCount = $Data->numRows();
     if (count($Result) > 0) {
         $this->LastCommentID = $Result[count($Result) - 1]->CommentID;
     } else {
         $this->LastCommentID = null;
     }
     // Now that we have th comments we can filter out the ones we don't have permission to.
     if ($Perms !== true) {
         $Remove = array();
         foreach ($Data->result() as $Index => $Row) {
             if (!in_array($Row->CategoryID, $Perms)) {
                 $Remove[] = $Index;
             }
         }
         if (count($Remove) > 0) {
             foreach ($Remove as $Index) {
                 unset($Result[$Index]);
             }
             $Result = array_values($Result);
         }
     }
     Gdn::userModel()->joinUsers($Data, array('InsertUserID', 'UpdateUserID'));
     $this->EventArguments['Comments'] =& $Data;
     $this->fireEvent('AfterGet');
     return $Data;
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:56,代码来源:class.commentmodel.php

示例5: GetFullByUrlCode

 /**
  * Get full data for a single category by its URL slug. Respects permissions.
  * 
  * @since 2.0.0
  * @access public
  *
  * @param string $UrlCode Unique category slug from URL.
  * @return object SQL results.
  */
 public function GetFullByUrlCode($UrlCode)
 {
     $Data = (object) self::Categories($UrlCode);
     // Check to see if the user has permission for this category.
     // Get the category IDs.
     $CategoryIDs = DiscussionModel::CategoryPermissions();
     if (is_array($CategoryIDs) && !in_array(GetValue('CategoryID', $Data), $CategoryIDs)) {
         $Data = FALSE;
     }
     return $Data;
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:20,代码来源:class.categorymodel.php

示例6: getByUser

 /**
  *
  * Get discussions for a user.
  *
  * Events: BeforeGetByUser
  *
  * @since 2.1
  * @access public
  *
  * @param int $UserID Which user to get discussions for.
  * @param int $Limit Max number to get.
  * @param int $Offset Number to skip.
  * @param int $LastDiscussionID A hint for quicker paging.
  * @param int $WatchUserID User to use for read/unread data.
  * @return Gdn_DataSet SQL results.
  */
 public function getByUser($UserID, $Limit, $Offset, $LastDiscussionID = false, $WatchUserID = false)
 {
     $Perms = DiscussionModel::CategoryPermissions();
     if (is_array($Perms) && empty($Perms)) {
         return new Gdn_DataSet(array());
     }
     // Allow us to set perspective of a different user.
     if (!$WatchUserID) {
         $WatchUserID = $UserID;
     }
     // The point of this query is to select from one comment table, but filter and sort on another.
     // This puts the paging into an index scan rather than a table scan.
     $this->SQL->select('d2.*')->select('d2.InsertUserID', '', 'FirstUserID')->select('d2.DateInserted', '', 'FirstDate')->select('d2.DateLastComment', '', 'LastDate')->select('d2.LastCommentUserID', '', 'LastUserID')->from('Discussion d')->join('Discussion d2', 'd.DiscussionID = d2.DiscussionID')->where('d.InsertUserID', $UserID)->orderBy('d.DiscussionID', 'desc');
     // Join in the watch data.
     if ($WatchUserID > 0) {
         $this->SQL->select('w.UserID', '', 'WatchUserID')->select('w.DateLastViewed, w.Dismissed, w.Bookmarked')->select('w.CountComments', '', 'CountCommentWatch')->select('w.Participated')->join('UserDiscussion w', 'd2.DiscussionID = w.DiscussionID and w.UserID = ' . $WatchUserID, 'left');
     } else {
         $this->SQL->select('0', '', 'WatchUserID')->select('now()', '', 'DateLastViewed')->select('0', '', 'Dismissed')->select('0', '', 'Bookmarked')->select('0', '', 'CountCommentWatch')->select('d.Announce', '', 'IsAnnounce');
     }
     if ($LastDiscussionID) {
         // The last comment id from the last page was given and can be used as a hint to speed up the query.
         $this->SQL->where('d.DiscussionID <', $LastDiscussionID)->limit($Limit);
     } else {
         $this->SQL->limit($Limit, $Offset);
     }
     $this->fireEvent('BeforeGetByUser');
     $Data = $this->SQL->get();
     $Result =& $Data->result();
     $this->LastDiscussionCount = $Data->numRows();
     if (count($Result) > 0) {
         $this->LastDiscussionID = $Result[count($Result) - 1]->DiscussionID;
     } else {
         $this->LastDiscussionID = null;
     }
     // Now that we have th comments we can filter out the ones we don't have permission to.
     if ($Perms !== true) {
         $Remove = array();
         foreach ($Data->result() as $Index => $Row) {
             if (!in_array($Row->CategoryID, $Perms)) {
                 $Remove[] = $Index;
             }
         }
         if (count($Remove) > 0) {
             foreach ($Remove as $Index) {
                 unset($Result[$Index]);
             }
             $Result = array_values($Result);
         }
     }
     // Change discussions returned based on additional criteria
     $this->AddDiscussionColumns($Data);
     // Join in the users.
     Gdn::userModel()->joinUsers($Data, array('FirstUserID', 'LastUserID'));
     CategoryModel::JoinCategories($Data);
     if (c('Vanilla.Views.Denormalize', false)) {
         $this->AddDenormalizedViews($Data);
     }
     $this->EventArguments['Data'] =& $Data;
     $this->fireEvent('AfterAddColumns');
     return $Data;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:77,代码来源:class.discussionmodel.php

示例7: joinRecords

 /**
  * Join external records to an array.
  *
  * @param array &$Data The data to join.
  * In order to join records each row must have the a RecordType and RecordID column.
  * @param string $Column The name of the column to put the record in.
  * If this is blank then the record will be merged into the row.
  * @param bool $Unset Whether or not to unset rows that don't have a record.
  * @since 2.3
  */
 function joinRecords(&$Data, $Column = '', $Unset = false)
 {
     $IDs = array();
     $AllowedCats = DiscussionModel::CategoryPermissions();
     if ($AllowedCats === false) {
         // This user does not have permission to view anything.
         $Data = array();
         return;
     }
     // Gather all of the ids to fetch.
     foreach ($Data as &$Row) {
         if (!$Row['RecordType']) {
             continue;
         }
         $RecordType = ucfirst(StringEndsWith($Row['RecordType'], '-Total', true, true));
         $Row['RecordType'] = $RecordType;
         $ID = $Row['RecordID'];
         $IDs[$RecordType][$ID] = $ID;
     }
     // Fetch all of the data in turn.
     $JoinData = array();
     foreach ($IDs as $RecordType => $RecordIDs) {
         if ($RecordType == 'Comment') {
             Gdn::SQL()->Select('d.Name, d.CategoryID')->Join('Discussion d', 'd.DiscussionID = r.DiscussionID');
         }
         $Rows = Gdn::SQL()->Select('r.*')->WhereIn($RecordType . 'ID', array_values($RecordIDs))->Get($RecordType . ' r')->ResultArray();
         $JoinData[$RecordType] = Gdn_DataSet::Index($Rows, array($RecordType . 'ID'));
     }
     // Join the rows.
     $Unsets = array();
     foreach ($Data as $Index => &$Row) {
         $RecordType = $Row['RecordType'];
         $ID = $Row['RecordID'];
         if (!isset($JoinData[$RecordType][$ID])) {
             if ($Unset) {
                 $Unsets[] = $Index;
             }
             continue;
             // orphaned?
         }
         $Record = $JoinData[$RecordType][$ID];
         if ($AllowedCats !== true) {
             // Check to see if the user has permission to view this record.
             $CategoryID = GetValue('CategoryID', $Record, -1);
             if (!in_array($CategoryID, $AllowedCats)) {
                 $Unsets[] = $Index;
                 continue;
             }
         }
         switch ($RecordType) {
             case 'Discussion':
                 $Url = DiscussionUrl($Record, '', '/') . '#latest';
                 break;
             case 'Comment':
                 $Url = CommentUrl($Record, '/');
                 $Record['Name'] = sprintf(T('Re: %s'), $Record['Name']);
                 break;
             default:
                 $Url = '';
         }
         $Record['Url'] = $Url;
         if ($Column) {
             $Row[$Column] = $Record;
         } else {
             $Row = array_merge($Row, $Record);
         }
     }
     foreach ($Unsets as $Index) {
         unset($Data[$Index]);
     }
     // Join the users.
     Gdn::UserModel()->JoinUsers($Data, array('InsertUserID'));
     if (!empty($Unsets)) {
         $Data = array_values($Data);
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:86,代码来源:functions.general.php

示例8: GetByUser

 /**
  * Get comments for a user.
  * 
  * @since 2.0.17
  * @access public
  * 
  * @param int $UserID Which user to get comments for.
  * @param int $Limit Max number to get.
  * @param int $Offset Number to skip.
  * @return object SQL results.
  */
 public function GetByUser($UserID, $Limit, $Offset = 0)
 {
     // Get category permissions
     $Perms = DiscussionModel::CategoryPermissions();
     // Build main query
     $this->CommentQuery(TRUE, FALSE);
     $this->FireEvent('BeforeGet');
     $this->SQL->Select('d.Name', '', 'DiscussionName')->Join('Discussion d', 'c.DiscussionID = d.DiscussionID')->Where('c.InsertUserID', $UserID)->OrderBy('c.CommentID', 'desc')->Limit($Limit, $Offset);
     // Verify permissions (restricting by category if necessary)
     if ($Perms !== TRUE) {
         $this->SQL->Join('Category ca', 'd.CategoryID = ca.CategoryID', 'left')->WhereIn('d.CategoryID', $Perms);
     }
     //$this->OrderBy($this->SQL);
     $Data = $this->SQL->Get();
     Gdn::UserModel()->JoinUsers($Data, array('InsertUserID', 'UpdateUserID'));
     return $Data;
 }
开发者ID:Raz0r,项目名称:Garden,代码行数:28,代码来源:class.commentmodel.php

示例9: GetFullByUrlCode

   /**
    * Get full data for a single category by its URL slug. Respects permissions.
    * 
    * @since 2.0.0
    * @access public
    *
    * @param string $UrlCode Unique category slug from URL.
    * @return object SQL results.
    */
   public function GetFullByUrlCode($UrlCode) {
      $this->SQL
         ->Select('c.*')
         ->From('Category c')
         ->Where('c.UrlCode', $UrlCode)
         ->Where('c.CategoryID >', 0);
         
      $Data = $this->SQL
         ->Get()
         ->FirstRow();

      // Check to see if the user has permission for this category.
      // Get the category IDs.
      $CategoryIDs = DiscussionModel::CategoryPermissions();
      if (is_array($CategoryIDs) && !in_array(GetValue('CategoryID', $Data), $CategoryIDs))
         $Data = FALSE;
      return $Data;
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:27,代码来源:class.categorymodel.php


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