Property | Type | Description | |
---|---|---|---|
$Watching | boolean |
Property | Type | Description | |
---|---|---|---|
$allowedFilters | The filters that are accessible via GET. Each filter corresponds with a where clause. You can have multiple filter sets. Every filter must be added to a filter set. Each filter set has the following properties: - **key**: string - The key name of the filter set. Appears in the query string, should be url-friendly. - **name**: string - The display name of the filter set. Usually appears in the UI. - **filters**: array - The filters in the set. Each filter in the array has the following properties: - **key**: string - The key name of the filter. Appears in the query string, should be url-friendly. - **setKey**: string - The key name of the filter set. - **name**: string - The display name of the filter. Usually appears as an option in the UI. - **where**: string - The where array query to execute for the filter. Uses - **group**: string - (optional) The dropdown module can group together any items with the same group name. | ||
$allowedSorts | The sorts that are accessible via GET. Each sort corresponds with an order by clause. Each sort in the array has the following properties: - **key**: string - The key name of the sort. Appears in the query string, should be url-friendly. - **name**: string - The display name of the sort. - **orderBy**: string - An array indicating order by fields and their directions in the format: ['field1' => 'direction', 'field2' => 'direction'] | ||
$filters | The filter keys of the wheres we apply in the query. | ||
$sort | The sort key of the order by we apply in the query. |
Method | Description | |
---|---|---|
__construct ( ) | Class constructor. Defines the related database table name. | |
addArchiveWhere ( object $Sql = null ) | Add SQL Where to account for archive date. | |
addDenormalizedViews ( Gdn_DataSet | stdClass &$Discussions ) | Add denormalized views to discussions. | |
addDiscussionColumns ( object $Data ) | Modifies discussion data before it is returned. | |
addFieldPrefix ( string $fieldName, string $prefix = 'd' ) : string | Adds a prefix to the field name if the field doesn't already have one. | |
addFilter ( string $key, string $name, array $wheres, string $group = '', string $setKey = 'filter' ) | Add a filter to the allowed filters array. | |
addFilterSet ( string $setKey, string $setName = '', array $categoryIDs = [] ) | Adds a filter set to the allowed filters array. | |
addSort ( string $key, string $name, string | array $orderBy, array $categoryIDs = [] ) | Add a sort to the allowed sorts array. | |
addView ( integer $DiscussionID ) | Increments view count for the specified discussion. | |
allowedSortFields ( ) | We don't use this functionality anymore. Previously, you had to register any sorting field before sorting with it. | |
bookmark ( integer $DiscussionID, integer $UserID, boolean | null $Bookmarked = null ) : boolean | Bookmarks (or unbookmarks) a discussion for the specified user. | |
bookmarkCount ( integer $DiscussionID ) : integer | Gets number of bookmarks specified discussion has (all users). | |
bookmarkDiscussion ( integer $DiscussionID, integer $UserID, &$Discussion = null ) : boolean | Bookmarks (or unbookmarks) a discussion for specified user. | |
calculate ( &$Discussion ) | ||
canEdit ( object | array $discussion, &$timeLeft ) : boolean | Determines whether or not the current user can edit a discussion. | |
canView ( object | array | integer $discussion, integer $userID ) : boolean | Tests whether a user has permission to view a specific discussion. | |
categoryPermissions ( boolean $Escape = false ) : array | Identify current user's category permissions and set as local array. | |
checkPermission ( object | array | integer $discussion, string $permission, integer $userID ) : boolean | Tests whether a user has permission for a discussion by checking category-specific permissions. | |
clearSorts ( ) | If you don't want to use any of the default sorts, use this little buddy. | |
counts ( $Column, $From = false, $To = false, $Max = false ) | ||
delete ( $where = [], $options = [] ) | ||
deleteID ( integer $discussionID, array $options = [] ) : boolean | Delete a discussion. Update and/or delete all related data. | |
discussionSummaryQuery ( array $AdditionalFields = [], $Join = true ) | Builds base SQL query for discussion data. | |
discussionTypes ( ) : array | Get the allowed discussion types. | |
dismissAnnouncement ( integer $DiscussionID, integer $UserID ) | Marks the specified announcement as dismissed by the specified user. | |
editContentTimeout ( object | array $discussion, integer &$timeLeft ) : boolean | Checks whether the time frame when a discussion can be edited has passed. | |
fetchPageInfo ( $Url, $ThrowError = false ) | ||
get ( integer $Offset = '0', integer $Limit = '', array $Wheres = '', array $AdditionalFields = null ) : Gdn_DataSet | Gets the data for multiple discussions based on the given criteria. | |
getAllowedFilters ( ) : array | Get the registered filters. | |
getAllowedSorts ( ) : array | ||
getAnnouncementCacheKey ( integer $CategoryID ) : string | ||
getAnnouncements ( array $Wheres = '', integer $Offset, integer $Limit = false ) : object | Gets announced discussions. | |
getBookmarkUsers ( integer $DiscussionID ) : object | Gets all users who have bookmarked the specified discussion. | |
getByUser ( integer $UserID, integer $Limit, integer $Offset, integer $LastDiscussionID = false, integer $WatchUserID = false ) : Gdn_DataSet | Get discussions for a user. | |
getCount ( array $Wheres = '', boolean $ForceNoAnnouncements = false ) : integer | Count how many discussions match the given criteria. | |
getCountForCategory ( integer | array $categoryID ) : integer | Get the count of discussions for an individual category. | |
getDefaultOrderBy ( ) : array | Returns an array of field => direction for the order by clause on the Discussion table. | |
getDefaultSortKey ( ) : string | ||
getFilters ( ) : array | ||
getForeignID ( integer $ForeignID, string $Type = '' ) : stdClass | Get data for a single discussion by ForeignID. | |
getID ( integer $DiscussionID, string $DataSetType = DATASET_TYPE_OBJECT, array $Options = [] ) : object | Get data for a single discussion by ID. | |
getIn ( array $DiscussionIDs ) : Gdn_DataSet | Get discussions that have IDs in the provided array. | |
getParticipatedUsers ( integer $DiscussionID ) : Gdn_DataSet | Get all the users that have participated in the discussion. | |
getSort ( ) : string | ||
getSortField ( ) : string | Get discussions sort order based on config and optional user preference. | |
getSortFilterQueryString ( string $selectedSort, array $selectedFilters, string $sortKeyToSet = '', array $filterKeysToSet = [] ) : string | Get the current sort/filter query string. | |
getUnread ( integer $Offset = '0', integer $Limit = '', array $Wheres = '', array $AdditionalFields = null ) : Gdn_DataSet | Gets the data for multiple unread discussions based on the given criteria. | |
getUnreadCount ( array $Wheres = '' ) : integer | Count how many discussions match the given criteria. | |
getUserScore ( integer $DiscussionID, integer $UserID ) : integer | Gets the discussion score for specified user. | |
getViewsFallback ( integer $DiscussionID ) : mixed | null | ||
getWhere ( array | false $Where = false, string $OrderFields = '', string $OrderDirection = '', integer | false $Limit = false, integer | false $Offset = false ) : Gdn_DataSet | Get a list of discussions. | |
getWhereRecent ( array | false $Where = [], boolean | false | integer $Limit = false, integer | false $Offset = false ) : Gdn_DataSet | Get a list of the most recent discussions. | |
incrementNewDiscussion ( integer | array | stdClass $Discussion ) | ||
notifyNewDiscussion ( integer | array | stdClass $Discussion, ActivityModel $ActivityModel, array $Activity ) | ||
removeAnnouncements ( object $Data ) | Removes undismissed announcements from the data. | |
removeFilter ( array $filterKeys ) | Removes a filters from the allowed filter array with the passed filter key/values. | |
removeFilterSet ( string $setKey ) | Removes a filter set from the allowed filter array with the passed set key. | |
removeSort ( string $key ) | Removes a sort from the allowed sort array with the passed key. | |
save ( array $FormPostValues, array $Settings = false ) : integer | Inserts or updates the discussion via form values. | |
setField ( integer $RowID, string $Property, mixed $Value = false ) | An event firing wrapper for Gdn_Model::setField(). | |
setFilters ( array $filters ) | Will only set the filters property if the passed filters exist in the allowed filters array. | |
setProperty ( integer $DiscussionID, string $Property, mixed $ForceValue = null ) : mixed | Updates a discussion field. | |
setSort ( string | array $sort ) | Set the discussion sort. | |
setUserBookmarkCount ( integer $UserID ) : integer | Update and get bookmark count for the specified user. | |
setUserScore ( integer $DiscussionID, integer $UserID, integer $Score ) : integer | Sets the discussion score for specified user. | |
updateDiscussionCount ( integer $CategoryID, array | false $Discussion = false ) | Update the CountDiscussions value on the category based on the CategoryID being saved. | |
updateUserDiscussionCount ( integer $UserID, boolean $Inc = false ) | Update a user's discussion count. | |
userBookmarkCount ( integer $UserID ) : integer | Gets number of bookmarks specified user has. |
Method | Description | |
---|---|---|
addClearFilter ( string $setKey, string $setName = '' ) | Adds an option to a filter set filters array to clear any existing filters on the data. | |
combineWheres ( array $newWheres, array $wheres ) : array | Combines two arrays of where clauses. | |
getFiltersFromArray ( array $array ) : array | Retrieves valid set key and filter keys pairs from an array, and returns the setKey => filterKey values. | |
getFiltersFromKeys ( array $filterKeyValues ) : array | Takes an array of filter key/values [setKey => filterKey] and returns a collection of filters. | |
getKeysFromFilters ( array $filters ) : array | Takes a collection of filters and returns the corresponding filter key/value array [setKey => filterKey]. | |
getOrderBy ( ) : array | Returns an array in the format [field => direction]. You can safely use return values from this function in the orderBy() SQL function. | |
getSortFromArray ( array $array ) : string | Retrieves the sort key from an array and if the value is valid, returns it. | |
getSortFromKey ( string $sortKey ) : array | ||
getSortFromString ( string $string ) : string | Checks the allowed sorts array for the string and it is valid, returns it the string. | |
getWheres ( array $categoryIDs = [] ) : array | Checks for any set filters and if they exist, returns the where clauses from the filters. |
Method | Description | |
---|---|---|
formatTags ( string $Tags ) : string | Convert tags from stored format to user-presentable format. |
public __construct ( ) |
public addArchiveWhere ( object $Sql = null ) | ||
$Sql | object | Gdn_SQLDriver |
protected static addClearFilter ( string $setKey, string $setName = '' ) | ||
$setKey | string | The key name of the filter set to add the option to. |
$setName | string | The display name of the option. Usually the human-readable set name. |
public addDenormalizedViews ( Gdn_DataSet | stdClass &$Discussions ) | ||
$Discussions | Gdn_DataSet | stdClass |
public addDiscussionColumns ( object $Data ) | ||
$Data | object | SQL result. |
public static addFilter ( string $key, string $name, array $wheres, string $group = '', string $setKey = 'filter' ) | ||
$key | string | The key name of the filter. Appears in the query string, should be url-friendly. |
$name | string | The display name of the filter. Usually appears as an option in the UI. |
$wheres | array | The where array query to execute for the filter. Uses |
$group | string | (optional) The nav module will group together any items with the same group name. |
$setKey | string | The key name of the filter set. |
public static addFilterSet ( string $setKey, string $setName = '', array $categoryIDs = [] ) | ||
$setKey | string | The key name of the filter set. |
$setName | string | The name of the filter set. Appears in the UI. |
$categoryIDs | array | The IDs of the categories that this filter will work on. If empty, filter is global. |
public static addSort ( string $key, string $name, string | array $orderBy, array $categoryIDs = [] ) | ||
$key | string | The key name of the sort. Appears in the query string, should be url-friendly. |
$name | string | The display name of the sort. |
$orderBy | string | array | An array indicating order by fields and their directions in the format: array('field1' => 'direction', 'field2' => 'direction') |
$categoryIDs | array | The IDs of the categories that this sort will work on. If empty, sort is global. |
public static allowedSortFields ( ) |
public bookmark ( integer $DiscussionID, integer $UserID, boolean | null $Bookmarked = null ) : boolean | ||
$DiscussionID | integer | The unique id of the discussion. |
$UserID | integer | The unique id of the user. |
$Bookmarked | boolean | null | Whether or not to bookmark or unbookmark. Pass null to toggle the bookmark. |
return | boolean | The new value of bookmarked. |
public bookmarkCount ( integer $DiscussionID ) : integer | ||
$DiscussionID | integer | Unique ID of discussion for which to tally bookmarks. |
return | integer | Total number of bookmarks. |
public bookmarkDiscussion ( integer $DiscussionID, integer $UserID, &$Discussion = null ) : boolean | ||
$DiscussionID | integer | Unique ID of discussion to (un)bookmark. |
$UserID | integer | Unique ID of user doing the (un)bookmarking. |
return | boolean | Current state of the bookmark (TRUE for bookmarked, FALSE for unbookmarked). |
public canView ( object | array | integer $discussion, integer $userID ) : boolean | ||
$discussion | object | array | integer | The discussion ID or the discussion to test. |
$userID | integer | The ID of the user to test permission for. If empty, it defaults to Session user. |
return | boolean | Whether the user can view the discussion. |
public static categoryPermissions ( boolean $Escape = false ) : array | ||
$Escape | boolean | Prepends category IDs with @ |
return | array | Protected local _CategoryPermissions |
public checkPermission ( object | array | integer $discussion, string $permission, integer $userID ) : boolean | ||
$discussion | object | array | integer | The discussion ID or the discussion to test. |
$permission | string | The category permission to test against the user. |
$userID | integer | The ID of the user to test permission for. If empty, it defaults to Session user. |
return | boolean | Whether the user has the specified permission privileges to the discussion. |
public static clearSorts ( ) |
public discussionSummaryQuery ( array $AdditionalFields = [], $Join = true ) | ||
$AdditionalFields | array | Allows selection of additional fields as Alias=>Table.Fieldname. |
public static discussionTypes ( ) : array | ||
return | array | Returns an array of discussion type definitions. |
public dismissAnnouncement ( integer $DiscussionID, integer $UserID ) | ||
$DiscussionID | integer | Unique ID of discussion being affected. |
$UserID | integer | Unique ID of the user being affected. |
public get ( integer $Offset = '0', integer $Limit = '', array $Wheres = '', array $AdditionalFields = null ) : Gdn_DataSet | ||
$Offset | integer | Number of discussions to skip. |
$Limit | integer | Max number of discussions to return. |
$Wheres | array | SQL conditions. |
$AdditionalFields | array | Allows selection of additional fields as Alias=>Table.Fieldname. |
return | Gdn_DataSet | SQL result. |
public static getAllowedFilters ( ) : array | ||
return | array | The current filter array. |
public static getAllowedSorts ( ) : array | ||
return | array | The current sort array. |
public getAnnouncementCacheKey ( integer $CategoryID ) : string | ||
$CategoryID | integer | Category ID, |
return | string | $Key CacheKey name to be used for cache. |
public getBookmarkUsers ( integer $DiscussionID ) : object | ||
$DiscussionID | integer | Unique ID to find bookmarks for. |
return | object | SQL result. |
public getByUser ( integer $UserID, integer $Limit, integer $Offset, integer $LastDiscussionID = false, integer $WatchUserID = false ) : Gdn_DataSet | ||
$UserID | integer | Which user to get discussions for. |
$Limit | integer | Max number to get. |
$Offset | integer | Number to skip. |
$LastDiscussionID | integer | A hint for quicker paging. |
$WatchUserID | integer | User to use for read/unread data. |
return | Gdn_DataSet | SQL results. |
public static getDefaultOrderBy ( ) : array | ||
return | array | The default order by fields |
protected getFiltersFromArray ( array $array ) : array | ||
$array | array | The array to get the filters from. |
return | array | The valid filters from the passed array or an empty array. |
protected getFiltersFromKeys ( array $filterKeyValues ) : array | ||
$filterKeyValues | array | The filters key array to get the filter for. |
return | array | An array of filters. |
public getForeignID ( integer $ForeignID, string $Type = '' ) : stdClass | ||
$ForeignID | integer | Foreign ID of discussion to get. |
$Type | string | The record type or an empty string for any record type. |
return | stdClass | SQL result. |
public getID ( integer $DiscussionID, string $DataSetType = DATASET_TYPE_OBJECT, array $Options = [] ) : object | ||
$DiscussionID | integer | Unique ID of discussion to get. |
$DataSetType | string | One of the **DATASET_TYPE_*** constants. |
$Options | array | An array of extra options for the query. |
return | object | SQL result. |
protected getKeysFromFilters ( array $filters ) : array | ||
$filters | array | The filters to get the keys for. |
return | array | The filter key array. |
protected getOrderBy ( ) : array | ||
return | array | An array of field => direction values. |
public getParticipatedUsers ( integer $DiscussionID ) : Gdn_DataSet | ||
$DiscussionID | integer | |
return | Gdn_DataSet |
public static getSortField ( ) : string | ||
return | string | Column name. |
public static getSortFilterQueryString ( string $selectedSort, array $selectedFilters, string $sortKeyToSet = '', array $filterKeysToSet = [] ) : string | ||
$selectedSort | string | |
$selectedFilters | array | |
$sortKeyToSet | string | The key name of the sort in the sorts array. |
$filterKeysToSet | array | An array of filters, where the key is the key of the filterSet in the filters array and the value is the key of the filter. |
return | string | The current or amended query string for sort and filter. |
protected getSortFromArray ( array $array ) : string | ||
$array | array | The array to get the sort from. |
return | string | The valid sort from the passed array or an empty string. |
protected getSortFromKey ( string $sortKey ) : array | ||
$sortKey | string | |
return | array |
protected getSortFromString ( string $string ) : string | ||
$string | string | The string to get the sort from. |
return | string | A valid sort key or an empty string. |
public getUnread ( integer $Offset = '0', integer $Limit = '', array $Wheres = '', array $AdditionalFields = null ) : Gdn_DataSet | ||
$Offset | integer | Number of discussions to skip. |
$Limit | integer | Max number of discussions to return. |
$Wheres | array | SQL conditions. |
$AdditionalFields | array | Allows selection of additional fields as Alias=>Table.Fieldname. |
return | Gdn_DataSet | SQL result. |
public getUnreadCount ( array $Wheres = '' ) : integer | ||
$Wheres | array | SQL conditions. |
return | integer | Number of discussions. |
public getWhere ( array | false $Where = false, string $OrderFields = '', string $OrderDirection = '', integer | false $Limit = false, integer | false $Offset = false ) : Gdn_DataSet | ||
$Where | array | false | The where condition of the get. |
$OrderFields | string | The field to order the discussions by. |
$OrderDirection | string | The order, either **asc** or **desc**. |
$Limit | integer | false | The number of discussion to return. |
$Offset | integer | false | The offset within the total set. |
return | Gdn_DataSet | Returns a {@link Gdn_DataSet} of discussions. |
public getWhereRecent ( array | false $Where = [], boolean | false | integer $Limit = false, integer | false $Offset = false ) : Gdn_DataSet | ||
$Where | array | false | The where condition of the get. |
$Limit | boolean | false | integer | The number of discussion to return. |
$Offset | integer | false | The offset within the total set. |
return | Gdn_DataSet | Returns a Gdn_DataSet of discussions. of discussions. |
public incrementNewDiscussion ( integer | array | stdClass $Discussion ) | ||
$Discussion | integer | array | stdClass | The discussion ID or discussion. |
public removeAnnouncements ( object $Data ) | ||
$Data | object | SQL result. |
public static removeFilter ( array $filterKeys ) | ||
$filterKeys | array | The key/value pairs of the filters to remove. |
public static removeFilterSet ( string $setKey ) | ||
$setKey | string | The key of the filter to remove. |
public static removeSort ( string $key ) | ||
$key | string | The key of the sort to remove. |
public setFilters ( array $filters ) | ||
$filters | array | The prospective filters to set. |
public setProperty ( integer $DiscussionID, string $Property, mixed $ForceValue = null ) : mixed | ||
$DiscussionID | integer | Unique ID of discussion being updated. |
$Property | string | Name of field to be updated. |
$ForceValue | mixed | If set, overrides toggle behavior with this value. |
return | mixed | Value that was ultimately set for the field. |
public setUserBookmarkCount ( integer $UserID ) : integer | ||
$UserID | integer | Unique ID of user to update. |
return | integer | Total number of bookmarks user has. |
public updateDiscussionCount ( integer $CategoryID, array | false $Discussion = false ) | ||
$CategoryID | integer | Unique ID of category we are updating. |
$Discussion | array | false | The discussion to update the count for or **false** for all of them. |
public updateUserDiscussionCount ( integer $UserID, boolean $Inc = false ) | ||
$UserID | integer | The user to calculate. |
$Inc | boolean | Whether to increment of recalculate from scratch. |
public userBookmarkCount ( integer $UserID ) : integer | ||
$UserID | integer | Unique ID of user for which to tally bookmarks. |
return | integer | Total number of bookmarks. |
protected static $allowedFilters |
protected static $allowedSorts |
protected $filters |