Stud.IP  5.4
ForumEntry Class Reference
Inheritance diagram for ForumEntry:
PrivacyObject

Static Public Member Functions

static br2space ($text)
 
static killEdit ($description)
 
static appendEdit ($description)
 
static parseEdit ($description, $anonymous=false)
 
static getContentAsHtml ($description, $anonymous=false)
 
static getEditComment ($description, $anonymous=false)
 
static getEditInfo ($description)
 
static removeQuotes ($description)
 
static killFormat ($text)
 
static getConstraints ($topic_id)
 
static getParentTopicId ($topic_id)
 
static getChildTopicIds ($topic_id)
 
static getPostingPage ($topic_id, $constraint=null)
 
static getLastUnread ($parent_id)
 
static getLatestPosting ($parent_id)
 
static getPathToPosting ($topic_id)
 
static getFlatPathToPosting ($topic_id)
 
static parseEntries ($postings)
 
static getEntries ($parent_id, $with_childs=false, $add='', $sort_order='DESC', $start=0, $limit=ForumEntry::POSTINGS_PER_PAGE)
 
static getLastPostings ($postings)
 
static getList ($type, $parent_id)
 
static getLatestSince ($parent_id, $start_date, $end_date)
 
static getSearchResults ($parent_id, $_searchfor, $options)
 
static getEntry ($topic_id)
 
static countEntries ($parent_id)
 
static countPostings ($course_id)
 
static countUserEntries ($user_id, $seminar_id=null)
 
static insert ($data, $parent_id)
 
static update ($topic_id, $name, $content)
 
static delete ($topic_id)
 
static move ($topic_id, $destination)
 
static close ($topic_id)
 
static open ($topic_id)
 
static sticky ($topic_id)
 
static unsticky ($topic_id)
 
static checkRootEntry ($seminar_id)
 
static getTopTenSeminars ()
 
static countAllEntries ()
 
static migrateUser ($user_from, $user_to)
 
static getDump ($seminar_id, $parent_id=null)
 
static isClosed ($topic_id)
 
static exportUserData (StoredUserData $storage)
 

Data Fields

const WITH_CHILDS = true
 
const WITHOUT_CHILDS = false
 
const THREAD_PREVIEW_LENGTH = 100
 
const POSTINGS_PER_PAGE = 10
 
const FEED_POSTINGS = 100
 

Member Function Documentation

◆ appendEdit()

static appendEdit (   $description)
static

add the edit-html to a posting

Parameters
string$descriptionthe posting-content
Returns
string the content with the edit-mark

◆ br2space()

static br2space (   $text)
static

is used for posting-preview. replaces all newlines with spaces

Parameters
string$textthe text to work on
Returns
string

◆ checkRootEntry()

static checkRootEntry (   $seminar_id)
static

check, if the default root-node for this seminar exists and make sure the default category exists as well

Parameters
string$seminar_id
Returns
void

◆ close()

static close (   $topic_id)
static

close the passed topic

Parameters
string$topic_idthe topic to close
Returns
void

◆ countAllEntries()

static countAllEntries ( )
static

count all entries that exists in the whole installation and return it.

Returns
int

◆ countEntries()

static countEntries (   $parent_id)
static

Count the number of child-elements that the passed entry has and return it.

Parameters
string$parent_id
Returns
int the number of child entries for the passed entry

◆ countPostings()

static countPostings (   $course_id)
static

Count the number of postings in a given course and return it.

Parameters
string$course_idthe id of the given course
Returns
int the number of postings in the course

◆ countUserEntries()

static countUserEntries (   $user_id,
  $seminar_id = null 
)
static

Count all entries the passed user has ever written and return the result

type $entries

Parameters
string$user_id
Returns
int number of entries user has ever written

◆ delete()

static delete (   $topic_id)
static

delete an entry and all his descendants from the mptt-table

Parameters
string$topic_idthe id of the entry to delete
Returns
void

◆ exportUserData()

static exportUserData ( StoredUserData  $storage)
static

Export available data of a given user into a storage object (an instance of the StoredUserData class) for that user.

Parameters
StoredUserData$storageobject to store data into

Implements PrivacyObject.

◆ getChildTopicIds()

static getChildTopicIds (   $topic_id)
static

get the topic_ids of all childs of the passed topic including itself

Parameters
string$topic_idthe topic_id to find the childs for
Returns
array a list if topic_ids

◆ getConstraints()

static getConstraints (   $topic_id)
static

returns the entry for the passed topic_id

Parameters
string$topic_id
Returns
array array('lft' => ..., 'rgt' => ..., seminar_id => ...)
Exceptions
Exception

◆ getContentAsHtml()

static getContentAsHtml (   $description,
  $anonymous = false 
)
static

Get content with appended edit comment as HTML.

Parameters
string$descriptionDatabase entry of forum entry's body.
bool$anonymousTrue, if only root is allowed to see authors.
Returns
string Content and edit comment as HTML.

◆ getDump()

static getDump (   $seminar_id,
  $parent_id = null 
)
static

returns the complete seminar or only the passed sub-tree as a html-string

Parameters
string$seminar_id
Returns
string

◆ getEditComment()

static getEditComment (   $description,
  $anonymous = false 
)
static

Get author and time of an edited forum entry as a string.

Parameters
string$descriptionDatabase entry of forum entry's body.
bool$anonymousTrue, if only root is allowed to see authors.
Returns
string Author and time or empty string if not edited.

◆ getEditInfo()

static getEditInfo (   $description)
static

Get author and time of an edited forum entry.

Parameters
string$descriptionDatabase entry of forum entry's body.
Returns
array Associative array containing author and time. boolean False if edit tag was not found.

◆ getEntries()

static getEntries (   $parent_id,
  $with_childs = false,
  $add = '',
  $sort_order = 'DESC',
  $start = 0,
  $limit = ForumEntry::POSTINGS_PER_PAGE 
)
static

Get all entries for the passed parent_id. Returns an array of the following structure: Array ( 'list' => Array ( 'author' => 'topic_id' => 'name' => formatReady() 'name_raw' => 'content' => formatReady() 'content_raw' => 'content_short' => 'chdate' => 'mkdate' => 'user_id' => 'raw_title' => 'raw_description' => 'fav' => 'depth' => 'sticky' => 'closed' => 'seminar_id' => ) 'count' => )

Parameters
string$parent_idid of parent-element to get entries for.
boolean$with_childsif true, the whole subtree is fetched
string$addfor additional constraints in the WHERE-part of the query
string$sort_ordercan be ASC or DESC
int$startcan be used for pagination, is used for the LIMIT-part of the query
int$limitnumber of entries to fetch, defaults to ForumEntry::POSTINGS_PER_PAGE
Returns
array
Exceptions
Exceptionif the retrieval failed, an Exception is thrown

◆ getEntry()

static getEntry (   $topic_id)
static

returns the entry for the passed topic_id

Parameters
string$topic_id
Returns
array hash-array with the entries fields

◆ getFlatPathToPosting()

static getFlatPathToPosting (   $topic_id)
static

returns a hashmap where key is topic_id and value a posting-title from the entries which lead to the passed topic.

WARNING: This function ommits postings with an empty title. For a full list please use ForumEntry::getPathToPosting()!

Parameters
string$topic_idthe topic to get the path for
Returns
array

◆ getLastPostings()

static getLastPostings (   $postings)
static

Takes a posting-array like the one generated by ForumEntry::getList() and adds the child-posting with the freshest creation-date to it.

Parameters
array$postings
Returns
array

◆ getLastUnread()

static getLastUnread (   $parent_id)
static

return the id for the oldest unread child-posting for the passed topic.

Parameters
string$parent_id
Returns
string id of oldest unread posting

◆ getLatestPosting()

static getLatestPosting (   $parent_id)
static

retrieve the the latest posting under $parent_id or false if the postings itself is the latest

Parameters
string$parent_idthe node to lookup the childs in
Returns
mixed the data for the latest postings or false

◆ getLatestSince()

static getLatestSince (   $parent_id,
  $start_date,
  $end_date 
)
static

Get the latest forum entries for the passed entries childs

Parameters
string$parent_id
int$start_datetimestamp
int$end_datetimestamp
Returns
array list of postings

◆ getList()

static getList (   $type,
  $parent_id 
)
static

get a list of postings of a special type

Parameters
string$typeone of 'area', 'list', 'postings', 'latest', 'favorites', 'dump', 'flat'
string$parent_idthe are to fetch from
Returns
array array('list' => ..., 'count' => ...);

◆ getParentTopicId()

static getParentTopicId (   $topic_id)
static

return the topic_id of the parent element, false if there is none (ie the passed topic_id is already the upper-most node in the tree)

Parameters
string$topic_idthe topic_id for which the parent shall be found
Returns
string the topic_id of the parent element or false

◆ getPathToPosting()

static getPathToPosting (   $topic_id)
static

returns a hashmap with arrays containing id and name with the entries which lead to the passed topic

Parameters
string$topic_idthe topic to get the path for
Returns
array

◆ getPostingPage()

static getPostingPage (   $topic_id,
  $constraint = null 
)
static

get the page the passed posting is on

Parameters
string$topic_id
Returns
int

◆ getSearchResults()

static getSearchResults (   $parent_id,
  $_searchfor,
  $options 
)
static

returns a list of postings for the passed search-term

Parameters
string$parent_idthe area to search in (can be a whole seminar)
string$_searchforthe term to search for
array$optionsfilter-options: search_title, search_content, search_author
Returns
array array('list' => ..., 'count' => ...);

◆ getTopTenSeminars()

static getTopTenSeminars ( )
static

returns the ten most active seminars

Returns
array

◆ insert()

static insert (   $data,
  $parent_id 
)
static

insert a node into the table

Parameters
array$dataan array containing the following fields: topic_id the id of the new topic seminar_id the id of the seminar to add the topic to user_id the id of the user who created the topic name the title of the entry content the content of the entry author the author's name as a plaintext string author_host ip-address of creator
string$parent_idthe node to add the topic to
Returns
void

◆ isClosed()

static isClosed (   $topic_id)
static

◆ killEdit()

static killEdit (   $description)
static

remove the edit-html from a posting

Parameters
string$descriptionthe posting-content
Returns
string the content stripped by the edit-mark

◆ killFormat()

static killFormat (   $text)
static

calls Stud.IP's kill_format

Parameters
string$textthe text to parse
Returns
string the text without format-tags

◆ migrateUser()

static migrateUser (   $user_from,
  $user_to 
)
static

updates the user-entries and replaces the old user-id by the new one

Parameters
string$user_from
string$user_to

◆ move()

static move (   $topic_id,
  $destination 
)
static

move the passed topic to the passed area

Parameters
string$topic_idthe topic to move
string$destinationthe area_id where the topic is moved to
Returns
void

◆ open()

static open (   $topic_id)
static

open the passed topic

Parameters
string$topic_idthe topic to open
Returns
void

◆ parseEdit()

static parseEdit (   $description,
  $anonymous = false 
)
static

convert the edit-html to raw text

Parameters
string$descriptionthe posting-content
Returns
string the content with the raw text version of the edit-mark

◆ parseEntries()

static parseEntries (   $postings)
static

fill the passed postings with additional data

Parameters
array$postings
Returns
array

◆ removeQuotes()

static removeQuotes (   $description)
static

Remove all quote blocks AND the quoted text from a forum post.

Parameters
String$stringThe string to remove the quote blocks from
Returns
String the posting without the [quote]-blocks (not just tags!)

◆ sticky()

static sticky (   $topic_id)
static

make the passed topic sticky

Parameters
string$topic_idthe topic to make sticky
Returns
void

◆ unsticky()

static unsticky (   $topic_id)
static

make the passed topic unsticky

Parameters
string$topic_idthe topic to make unsticky
Returns
void

◆ update()

static update (   $topic_id,
  $name,
  $content 
)
static

update the passed topic

Parameters
string$topic_idthe id of the topic to update
string$namethe new name
string$contentthe new content
Returns
void

Field Documentation

◆ FEED_POSTINGS

const FEED_POSTINGS = 100

◆ POSTINGS_PER_PAGE

const POSTINGS_PER_PAGE = 10

◆ THREAD_PREVIEW_LENGTH

const THREAD_PREVIEW_LENGTH = 100

◆ WITH_CHILDS

const WITH_CHILDS = true

◆ WITHOUT_CHILDS

const WITHOUT_CHILDS = false

The documentation for this class was generated from the following file: