Properties

$_forum

$_forum : array

Current forum data

Type

array

$_forum_id

$_forum_id : string

Current forum ID

Type

string

$_charset

$_charset : string

Charset

Type

string

$_db

$_db : \Horde_Db_Adapter

The database connection object.

Type

\Horde_Db_Adapter

$_scope

$_scope : string

The forums scope.

Type

string

$_threads_table

$_threads_table : string

Scope theads table name

Type

string

$_forums_table

$_forums_table : string

Scope theads table name

Type

string

$_cache

$_cache : \Horde_Cache

Cache object

Type

\Horde_Cache

Methods

__construct()

__construct(  $scope,   $params) 

Constructor

Parameters

$scope
$params

allowAttachments()

allowAttachments() : boolean

Checks if attachments are allowed in messages for the current forum.

Returns

boolean —

Whether attachments allowed or not.

saveMessage()

saveMessage(array  $info) : mixed

Saves the message.

Parameters

array $info

Array containing all the message data to save.

Throws

\Agora_Exception

Returns

mixed —

Message ID on success or PEAR_Error on failure.

moveThread()

moveThread(integer  $thread_id, integer  $forum_id) 

Moves a thread to another forum.

Parameters

integer $thread_id

The ID of the thread to move.

integer $forum_id

The ID of the destination forum.

Throws

\Agora_Exception

splitThread()

splitThread(integer  $message_id) 

Splits a thread on message id.

Parameters

integer $message_id

The ID of the message to split at.

Throws

\Agora_Exception

mergeThread()

mergeThread(  $thread_from, integer  $message_id) 

Merges two threads.

Parameters

$thread_from
integer $message_id

The ID of the message to merge to.

Throws

\Agora_Exception

getMessage()

getMessage(integer  $message_id) 

Fetches a message.

Parameters

integer $message_id

The ID of the message to fetch.

Throws

\Horde_Exception_NotFound
\Agora_Exception

replyMessage()

replyMessage(mixed  $message) : array

Returns a hash with all information necessary to reply to a message.

Parameters

mixed $message

The ID of the parent message to reply to, or arry of its data.

Throws

\Horde_Exception_NotFound
\Agora_Exception

Returns

array —

A hash with all relevant information.

deleteMessage()

deleteMessage(integer  $message_id) : string

Deletes a message and all replies.

Parameters

integer $message_id

The ID of the message to delete.

Throws

\Agora_Exception

Returns

string —

Thread ID on success.

_forumSequence()

_forumSequence(integer  $forum_id, string  $type = 'message', integer|string  $diff = '+') 

Increments or decrements a forum's message count.

Parameters

integer $forum_id

Forum to update

string $type

What to increment message, thread or view.

integer|string $diff

Incremental or decremental step, either a positive or negative integer, or a plus or minus sign.

deleteThread()

deleteThread(integer  $thread_id) 

Deletes an entire message thread.

Parameters

integer $thread_id

The ID of the thread to delete. If not specified will delete all the threads for the current forum.

Throws

\Agora_Exception

getThreads()

getThreads(integer  $thread_root, boolean  $all_levels = false, string  $sort_by = 'message_timestamp', integer  $sort_dir, boolean  $message_view = false, string  $link_back = '', string  $base_url = null, string  $from = null, string  $count = null, boolean  $nofollow = false) 

Returns a list of threads.

Parameters

integer $thread_root

Message at which to start the thread. If null get all forum threads

boolean $all_levels

Show all child levels or just one level.

string $sort_by

The column by which to sort.

integer $sort_dir

The direction by which to sort: 0 - ascending 1 - descending

boolean $message_view
string $link_back

A url to pass to the reply script which will be returned to after an insertion of a post. Useful in cases when this thread view is used in blocks to return to the original page rather than to Agora.

string $base_url

An alternative URL where edit/delete links point to. Mainly for api usage. Takes "%p" as a placeholder for the parent message ID.

string $from

The thread to start listing at.

string $count

The number of threads to return.

boolean $nofollow

Whether to set the 'rel="nofollow"' attribute on linked URLs in the messages.

formatBody()

formatBody(string  $body) 

Formats a message body.

Parameters

string $body

Text to format.

isHot()

isHot(  $views,   $last_post) 

Returns true if the message is hot.

Parameters

$views
$last_post

isNew()

isNew(  $thread_id,   $last_post) 

Returns true, has new posts since user last visit

Parameters

$thread_id
$last_post

getModerateList()

getModerateList(string  $sort_by, integer  $sort_dir) 

Fetches a list of messages awaiting moderation. Selects all messages, irrespective of the thread root, which have the 'moderate' flag set in the attributes.

Parameters

string $sort_by

The column by which to sort.

integer $sort_dir

The direction by which to sort: 0 - ascending 1 - descending

Throws

\Agora_Exception

getBanned()

getBanned() 

Get banned users from the current forum

updateBan()

updateBan(string  $user, integer  $forum_id = null, string  $action = 'add') 

Ban user on a specific forum.

Parameters

string $user

Moderator username.

integer $forum_id

Forum to add moderator to.

string $action

Action to peform ('add' or 'delete').

updateModerator()

updateModerator(string  $moderator, integer  $forum_id = null, string  $action = 'add') 

Updates forum moderators.

Parameters

string $moderator

Moderator username.

integer $forum_id

Forum to add moderator to.

string $action

Action to peform ('add' or 'delete').

Throws

\Agora_Exception

moderate()

moderate(string  $action, array  $ids) 

Approves one or more ids.

Parameters

string $action

Whether to 'approve' or 'delete' messages.

array $ids

Array of message IDs.

Throws

\Agora_Exception

countThreads()

countThreads(integer  $thread_root) : integer

Returns the number of replies on a thread, or threads in a forum

Parameters

integer $thread_root

Thread to count.

Returns

integer —

The number of messages in thread or PEAR_Error on failure.

countMessages()

countMessages() : integer

Returns the number of all messages (threads and replies) in a forum

Returns

integer —

The number of messages in forum or PEAR_Error on failure.

getThreadsUi()

getThreadsUi(array  $threads, array  $col_headers, boolean  $bodies = false, string  $template_file = false) : string

Returns a table showing the specified message list.

Parameters

array $threads

A hash with the thread messages as returned by {@link Agora_Driver::getThreads}.

array $col_headers

A hash with the column headers.

boolean $bodies

Display the message bodies?

string $template_file

Template to use.

Returns

string —

The rendered message table.

getThreadRoot()

getThreadRoot(  $message_id) 

Parameters

$message_id

Throws

\Agora_Exception

setThreadLock()

setThreadLock(  $message_id,   $lock) 

Parameters

$message_id
$lock

isThreadLocked()

isThreadLocked(  $message_id) : boolean

Parameters

$message_id

Returns

boolean

getThreadActions()

getThreadActions() 

getForm()

getForm(  $vars,   $title,   $editing = false,   $new_forum = false) 

Parameters

$vars
$title
$editing
$new_forum

dateFormat()

dateFormat(integer  $timestamp) : string

Formats time according to user preferences.

Parameters

integer $timestamp

Message timestamp.

Returns

string —

Formatted date.

logView()

logView(  $thread_id) : boolean

Logs a message view.

Parameters

$thread_id

Throws

\Agora_Exception

Returns

boolean —

True, if the view was logged, false if the message was aleredy seen

getAttachmentLink()

getAttachmentLink(  $message_id) 

Constructs message attachments link.

Parameters

$message_id

Throws

\Agora_Exception

formatSize()

formatSize(integer  $filesize) : string

Formats file size.

Parameters

integer $filesize

Returns

string —

Formatted filesize.

getForum()

getForum(integer  $forum_id) : array

Fetches a forum data.

Parameters

integer $forum_id

The ID of the forum to fetch.

Throws

\Horde_Exception_NotFound
\Agora_Exception

Returns

array —

The forum hash or a PEAR_Error on failure.

countForums()

countForums() 

Returns the number of forums.

getForums()

getForums(integer  $root_forum, boolean  $formatted = true, string  $sort_by = 'forum_name', integer  $sort_dir, boolean  $add_scope = false, string  $from, string  $count) : mixed

Fetches a list of forums.

Parameters

integer $root_forum

The first level forum.

boolean $formatted

Whether to return the list formatted or raw.

string $sort_by

The column to sort by.

integer $sort_dir

Sort direction, 0 = ascending, 1 = descending.

boolean $add_scope

Add parent forum if forum for another scopelication.

string $from

The forum to start listing at.

string $count

The number of forums to return.

Throws

\Agora_Exception

Returns

mixed —

An array of forums or PEAR_Error on failure.

getBareForums()

getBareForums() : array

Get forums ids and titles

Returns

array —

An array of forums and form names.

newForum()

newForum(string  $forum_name,   $owner) : integer

Creates a new forum.

Parameters

string $forum_name

Forum name.

$owner

Throws

\Agora_Exception

Returns

integer —

ID of the new generated forum.

saveForum()

saveForum(array  $info) : integer

Saves a forum, either creating one if no forum ID is given or updating an existing one.

Parameters

array $info

The forum information to save consisting of: forum_id forum_author forum_parent_id forum_name forum_moderated forum_description forum_attachments

Throws

\Agora_Exception

Returns

integer —

The forum ID on success.

deleteForum()

deleteForum(integer  $forum_id) : boolean

Deletes a forum, any subforums that are present and all messages contained in the forum and subforums.

Parameters

integer $forum_id

The ID of the forum to delete.

Throws

\Agora_Exception

Returns

boolean —

True on success.

search()

search(array  $filter, string  $sort_by = 'message_subject', integer  $sort_dir, string  $from, string  $count) : array

Searches forums for matching threads or posts.

Parameters

array $filter

Hash of filter criteria: 'forums' => Array of forum IDs to search. If not present, searches all forums. 'keywords' => Array of keywords to search for. If not present, finds all posts/threads. 'allkeywords' => Boolean specifying whether to find all keywords; otherwise, wants any keyword. False if not supplied. 'message_author' => Name of author to find posts by. If not present, any author. 'searchsubjects' => Boolean specifying whether to search subjects. True if not supplied. 'searchcontents' => Boolean specifying whether to search post contents. False if not supplied.

string $sort_by

The column by which to sort.

integer $sort_dir

The direction by which to sort: 0 - ascending 1 - descending

string $from

The thread to start listing at.

string $count

The number of threads to return.

Throws

\Agora_Exception

Returns

array —

A search result hash where: 'results' => Array of messages. 'total => Total message number.

hasPermission()

hasPermission(integer  $perm = \Horde_Perms::READ, integer  $forum_id = null, string  $scope = null) : boolean

Finds out if the user has the specified rights to the messages forum.

Parameters

integer $perm

The permission level needed for access.

integer $forum_id

Forum to check permissions for.

string $scope

Application scope to use.

Returns

boolean —

True if the user has the specified permissions.

convertFromDriver()

convertFromDriver(mixed  $value) : mixed

Converts a value from the driver's charset to the default charset.

Parameters

mixed $value

A value to convert.

Returns

mixed —

The converted value.

convertToDriver()

convertToDriver(mixed  $value) : mixed

Converts a value from the default charset to the driver's charset.

Parameters

mixed $value

A value to convert.

Returns

mixed —

The converted value.

getForumId()

getForumId(string  $forum_name) : integer

Returns an ID for a given forum name.

Parameters

string $forum_name

The full forum name.

Returns

integer —

The ID of the forum.

getThreadsByForumOwner()

getThreadsByForumOwner(string  $forum_owner, integer  $thread_root, boolean  $all_levels = false, string  $sort_by = 'message_modifystamp', integer  $sort_dir, boolean  $message_view = false, string  $from, string  $count) 

Returns a list of threads.

Parameters

string $forum_owner

Forum owner

integer $thread_root

Message at which to start the thread. If null get all forum threads

boolean $all_levels

Show all child levels or just one level.

string $sort_by

The column by which to sort.

integer $sort_dir

The direction by which to sort: 0 - ascending 1 - descending

boolean $message_view
string $from

The thread to start listing at.

string $count

The number of threads to return.

Throws

\Agora_Exception

_formatThreads()

_formatThreads(array|\Traversable  $messages, string  $sort_by = 'message_modifystamp', boolean  $format = false, integer  $thread_root) 

Formats a message body.

Parameters

array|\Traversable $messages

Messages to format

string $sort_by

List format order

boolean $format

Format messages body

integer $thread_root

Thread root

_getForums()

_getForums(integer  $root_forum, boolean  $formatted = true, string  $sort_by = 'forum_name', integer  $sort_dir, boolean  $add_scope = false, string  $from, string  $count) : array

Fetches a list of forums.

Parameters

integer $root_forum

The first level forum.

boolean $formatted

Whether to return the list formatted or raw.

string $sort_by

The column to sort by.

integer $sort_dir

Sort direction, 0 = ascending, 1 = descending.

boolean $add_scope

Add parent forum if forum for another scopelication.

string $from

The forum to start listing at.

string $count

The number of forums to return.

Throws

\Horde_Exception_NotFound
\Agora_Exception

Returns

array —

An array of forums.

_formatForums()

_formatForums(integer  $forums) : array|\Traversable

Fetches a list of forums.

Parameters

integer $forums

Forums to format

Throws

\Agora_Exception

Returns

array|\Traversable —

An array of forums.

_getCache()

_getCache(  $key,   $thread) 

Get cache value

Parameters

$key
$thread

_setCache()

_setCache(  $key,   $value,   $thread) 

Set cache value

Parameters

$key
$value
$thread

_getThreads()

_getThreads(integer  $thread_root, boolean  $all_levels = false, string  $sort_by = 'message_modifystamp', integer  $sort_dir, boolean  $message_view = false, string  $from, string  $count) 

Returns a list of threads.

Parameters

integer $thread_root

Message at which to start the thread. If null get all forum threads

boolean $all_levels

Show all child levels or just one level.

string $sort_by

The column by which to sort.

integer $sort_dir

The direction by which to sort: 0 - ascending 1 - descending

boolean $message_view
string $from

The thread to start listing at.

string $count

The number of threads to return.

Throws

\Agora_Exception

_lastInForum()

_lastInForum(integer  $forum_id, integer  $message_id, string  $message_author = '', integer  $message_timestamp) 

Update lastMessage in a Forum

Parameters

integer $forum_id

Forum to update

integer $message_id

Last message id

string $message_author

Last message author

integer $message_timestamp

Last message timestamp

Throws

\Agora_Exception

_lastInThread()

_lastInThread(integer  $thread_id, integer  $message_id, string  $message_author = '', integer  $message_timestamp) 

Update lastMessage in Thread

Parameters

integer $thread_id

Thread to update

integer $message_id

Last message id

string $message_author

Last message author

integer $message_timestamp

Last message timestamp

Throws

\Agora_Exception

_sequence()

_sequence(integer  $thread_id, integer|string  $diff = '+') 

Increments or decrements a thread's message count.

Parameters

integer $thread_id

Thread to update.

integer|string $diff

Incremental or decremental step, either a positive or negative integer, or a plus or minus sign.

_updateCacheState()

_updateCacheState(  $thread) 

Increment namespace

Parameters

$thread

_getCacheKey()

_getCacheKey(  $key,   $thread) 

Append namespace to cache key

Parameters

$key
$thread

_buildThreadsQuery()

_buildThreadsQuery(string  $forum_owner = null, integer  $thread_root, boolean  $all_levels = false, string  $sort_by = 'message_modifystamp', integer  $sort_dir, boolean  $message_view = false, string  $from, string  $count) 

Build threads query.

Parameters

string $forum_owner

Forum owner

integer $thread_root

Message at which to start the thread. If null get all forum threads

boolean $all_levels

Show all child levels or just one level.

string $sort_by

The column by which to sort.

integer $sort_dir

The direction by which to sort: 0 - ascending 1 - descending

boolean $message_view
string $from

The thread to start listing at.

string $count

The number of threads to return.