PHP Класс Agora_Driver, horde

Copyright 2003-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.
Автор: Marko Djukic ([email protected])
Автор: Jan Schneider ([email protected])
Автор: Duck ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$_forum array Current forum data
$_forum_id string Current forum ID

Защищенные свойства (Protected)

Свойство Тип Описание
$_cache Horde_Cache Cache object
$_charset string Charset
$_db Horde_Db_Adapter The database connection object.
$_forums_table string Scope theads table name
$_scope string The forums scope.
$_threads_table string Scope theads table name

Открытые методы

Метод Описание
__construct ( $scope, $params ) Constructor
_forumSequence ( integer $forum_id, string $type = 'message', integer | string $diff = '+' ) Increments or decrements a forum's message count.
allowAttachments ( ) : boolean Checks if attachments are allowed in messages for the current forum.
convertFromDriver ( mixed $value ) : mixed Converts a value from the driver's charset to the default charset.
convertToDriver ( mixed $value ) : mixed Converts a value from the default charset to the driver's charset.
countForums ( ) Returns the number of forums.
countMessages ( ) : integer Returns the number of all messages (threads and replies) in a forum
countThreads ( integer $thread_root ) : integer Returns the number of replies on a thread, or threads in a forum
dateFormat ( integer $timestamp ) : string Formats time according to user preferences.
deleteForum ( integer $forum_id ) : boolean Deletes a forum, any subforums that are present and all messages contained in the forum and subforums.
deleteMessage ( integer $message_id ) : string Deletes a message and all replies.
deleteThread ( integer $thread_id ) Deletes an entire message thread.
formatBody ( string $body ) Formats a message body.
formatSize ( integer $filesize ) : string Formats file size.
getAttachmentLink ( $message_id ) Constructs message attachments link.
getBanned ( ) Get banned users from the current forum
getBareForums ( ) : array Get forums ids and titles
getForm ( $vars, $title, $editing = false, $new_forum = false )
getForum ( integer $forum_id ) : array Fetches a forum data.
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.
getMessage ( integer $message_id ) Fetches a message.
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.
getThreadActions ( )
getThreadRoot ( $message_id )
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.
getThreadsUi ( array $threads, array $col_headers, boolean $bodies = false, string $template_file = false ) : string Returns a table showing the specified message list.
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.
isHot ( $views, $last_post ) Returns true if the message is hot.
isNew ( $thread_id, $last_post ) Returns true, has new posts since user last visit
isThreadLocked ( $message_id ) : boolean
logView ( $thread_id ) : boolean Logs a message view.
mergeThread ( $thread_from, integer $message_id ) Merges two threads.
moderate ( string $action, array $ids ) Approves one or more ids.
moveThread ( integer $thread_id, integer $forum_id ) Moves a thread to another forum.
newForum ( string $forum_name, $owner ) : integer Creates a new forum.
replyMessage ( mixed $message ) : array Returns a hash with all information necessary to reply to a message.
saveForum ( array $info ) : integer Saves a forum, either creating one if no forum ID is given or updating an existing one.
saveMessage ( array $info ) : mixed Saves the message.
search ( array $filter, string $sort_by = 'message_subject', integer $sort_dir, string $from, string $count ) : array Searches forums for matching threads or posts.
setThreadLock ( $message_id, $lock )
splitThread ( integer $message_id ) Splits a thread on message id.
updateBan ( string $user, integer $forum_id = null, string $action = 'add' ) Ban user on a specific forum.
updateModerator ( string $moderator, integer $forum_id = null, string $action = 'add' ) Updates forum moderators.

Защищенные методы

Метод Описание
_formatForums ( integer $forums ) : array | Traversable Fetches a list of forums.
_formatThreads ( array | Traversable $messages, string $sort_by = 'message_modifystamp', boolean $format = false, integer $thread_root ) Formats a message body.
_getCache ( $key, $thread ) Get cache value
_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.
_setCache ( $key, $value, $thread ) Set cache value

Приватные методы

Метод Описание
_getCacheKey ( $key, $thread ) Append namespace to cache key
_lastInForum ( integer $forum_id, integer $message_id, string $message_author = '', integer $message_timestamp ) Update lastMessage in a Forum
_lastInThread ( integer $thread_id, integer $message_id, string $message_author = '', integer $message_timestamp ) Update lastMessage in Thread
_sequence ( integer $thread_id, integer | string $diff = '+' ) Increments or decrements a thread's message count.
_updateCacheState ( $thread ) Increment namespace

Описание методов

__construct() публичный Метод

Constructor
public __construct ( $scope, $params )

_formatForums() защищенный Метод

Fetches a list of forums.
protected _formatForums ( integer $forums ) : array | Traversable
$forums integer Forums to format
Результат array | Traversable An array of forums.

_formatThreads() защищенный Метод

Formats a message body.
protected _formatThreads ( array | Traversable $messages, string $sort_by = 'message_modifystamp', boolean $format = false, integer $thread_root )
$messages array | Traversable Messages to format
$sort_by string List format order
$format boolean Format messages body
$thread_root integer Thread root

_forumSequence() публичный Метод

Increments or decrements a forum's message count.
public _forumSequence ( integer $forum_id, string $type = 'message', integer | string $diff = '+' )
$forum_id integer Forum to update
$type string What to increment message, thread or view.
$diff integer | string Incremental or decremental step, either a positive or negative integer, or a plus or minus sign.

_getCache() защищенный Метод

Get cache value
protected _getCache ( $key, $thread )

_getForums() защищенный Метод

Fetches a list of forums.
protected _getForums ( integer $root_forum, boolean $formatted = true, string $sort_by = 'forum_name', integer $sort_dir, boolean $add_scope = false, string $from, string $count ) : mixed
$root_forum integer The first level forum.
$formatted boolean Whether to return the list formatted or raw.
$sort_by string The column to sort by.
$sort_dir integer Sort direction, 0 = ascending, 1 = descending.
$add_scope boolean Add parent forum if forum for another scopelication.
$from string The forum to start listing at.
$count string The number of forums to return.
Результат mixed An array of forums or PEAR_Error on failure.

_setCache() защищенный Метод

Set cache value
protected _setCache ( $key, $value, $thread )

allowAttachments() публичный Метод

Checks if attachments are allowed in messages for the current forum.
public allowAttachments ( ) : boolean
Результат boolean Whether attachments allowed or not.

convertFromDriver() публичный Метод

Converts a value from the driver's charset to the default charset.
public convertFromDriver ( mixed $value ) : mixed
$value mixed A value to convert.
Результат mixed The converted value.

convertToDriver() публичный Метод

Converts a value from the default charset to the driver's charset.
public convertToDriver ( mixed $value ) : mixed
$value mixed A value to convert.
Результат mixed The converted value.

countForums() публичный Метод

Returns the number of forums.
public countForums ( )

countMessages() публичный Метод

Returns the number of all messages (threads and replies) in a forum
public countMessages ( ) : integer
Результат integer The number of messages in forum or PEAR_Error on failure.

countThreads() публичный Метод

Returns the number of replies on a thread, or threads in a forum
public countThreads ( integer $thread_root ) : integer
$thread_root integer Thread to count.
Результат integer The number of messages in thread or PEAR_Error on failure.

dateFormat() публичный Метод

Formats time according to user preferences.
public dateFormat ( integer $timestamp ) : string
$timestamp integer Message timestamp.
Результат string Formatted date.

deleteForum() публичный Метод

Deletes a forum, any subforums that are present and all messages contained in the forum and subforums.
public deleteForum ( integer $forum_id ) : boolean
$forum_id integer The ID of the forum to delete.
Результат boolean True on success.

deleteMessage() публичный Метод

Deletes a message and all replies.
public deleteMessage ( integer $message_id ) : string
$message_id integer The ID of the message to delete.
Результат string Thread ID on success.

deleteThread() публичный Метод

Deletes an entire message thread.
public deleteThread ( integer $thread_id )
$thread_id integer The ID of the thread to delete. If not specified will delete all the threads for the current forum.

formatBody() публичный Метод

Formats a message body.
public formatBody ( string $body )
$body string Text to format.

formatSize() публичный Метод

Formats file size.
public formatSize ( integer $filesize ) : string
$filesize integer
Результат string Formatted filesize.

getBanned() публичный Метод

Get banned users from the current forum
public getBanned ( )

getBareForums() публичный Метод

Get forums ids and titles
public getBareForums ( ) : array
Результат array An array of forums and form names.

getForm() публичный Метод

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

getForum() публичный Метод

Fetches a forum data.
public getForum ( integer $forum_id ) : array
$forum_id integer The ID of the forum to fetch.
Результат array The forum hash or a PEAR_Error on failure.

getForums() публичный Метод

Fetches a list of forums.
public getForums ( integer $root_forum, boolean $formatted = true, string $sort_by = 'forum_name', integer $sort_dir, boolean $add_scope = false, string $from, string $count ) : mixed
$root_forum integer The first level forum.
$formatted boolean Whether to return the list formatted or raw.
$sort_by string The column to sort by.
$sort_dir integer Sort direction, 0 = ascending, 1 = descending.
$add_scope boolean Add parent forum if forum for another scopelication.
$from string The forum to start listing at.
$count string The number of forums to return.
Результат mixed An array of forums or PEAR_Error on failure.

getMessage() публичный Метод

Fetches a message.
public getMessage ( integer $message_id )
$message_id integer The ID of the message to fetch.

getModerateList() публичный Метод

Fetches a list of messages awaiting moderation. Selects all messages, irrespective of the thread root, which have the 'moderate' flag set in the attributes.
public getModerateList ( string $sort_by, integer $sort_dir )
$sort_by string The column by which to sort.
$sort_dir integer The direction by which to sort: 0 - ascending 1 - descending

getThreadActions() публичный Метод

public getThreadActions ( )

getThreadRoot() публичный Метод

public getThreadRoot ( $message_id )

getThreads() публичный Метод

Returns a list of threads.
public 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 )
$thread_root integer Message at which to start the thread. If null get all forum threads
$all_levels boolean Show all child levels or just one level.
$sort_by string The column by which to sort.
$sort_dir integer The direction by which to sort: 0 - ascending 1 - descending
$message_view boolean
$link_back string 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.
$base_url string An alternative URL where edit/delete links point to. Mainly for api usage. Takes "%p" as a placeholder for the parent message ID.
$from string The thread to start listing at.
$count string The number of threads to return.
$nofollow boolean Whether to set the 'rel="nofollow"' attribute on linked URLs in the messages.

getThreadsUi() публичный Метод

Returns a table showing the specified message list.
public getThreadsUi ( array $threads, array $col_headers, boolean $bodies = false, string $template_file = false ) : string
$threads array A hash with the thread messages as returned by {@link Agora_Driver::getThreads}.
$col_headers array A hash with the column headers.
$bodies boolean Display the message bodies?
$template_file string Template to use.
Результат string The rendered message table.

hasPermission() публичный Метод

Finds out if the user has the specified rights to the messages forum.
public hasPermission ( integer $perm = Horde_Perms::READ, integer $forum_id = null, string $scope = null ) : boolean
$perm integer The permission level needed for access.
$forum_id integer Forum to check permissions for.
$scope string Application scope to use.
Результат boolean True if the user has the specified permissions.

isHot() публичный Метод

Returns true if the message is hot.
public isHot ( $views, $last_post )

isNew() публичный Метод

Returns true, has new posts since user last visit
public isNew ( $thread_id, $last_post )

isThreadLocked() публичный Метод

public isThreadLocked ( $message_id ) : boolean
Результат boolean

logView() публичный Метод

Logs a message view.
public logView ( $thread_id ) : boolean
Результат boolean True, if the view was logged, false if the message was aleredy seen

mergeThread() публичный Метод

Merges two threads.
public mergeThread ( $thread_from, integer $message_id )
$message_id integer The ID of the message to merge to.

moderate() публичный Метод

Approves one or more ids.
public moderate ( string $action, array $ids )
$action string Whether to 'approve' or 'delete' messages.
$ids array Array of message IDs.

moveThread() публичный Метод

Moves a thread to another forum.
public moveThread ( integer $thread_id, integer $forum_id )
$thread_id integer The ID of the thread to move.
$forum_id integer The ID of the destination forum.

newForum() публичный Метод

Creates a new forum.
public newForum ( string $forum_name, $owner ) : integer
$forum_name string Forum name.
Результат integer ID of the new generated forum.

replyMessage() публичный Метод

Returns a hash with all information necessary to reply to a message.
public replyMessage ( mixed $message ) : array
$message mixed The ID of the parent message to reply to, or arry of its data.
Результат array A hash with all relevant information.

saveForum() публичный Метод

Saves a forum, either creating one if no forum ID is given or updating an existing one.
public saveForum ( array $info ) : integer
$info array The forum information to save consisting of: forum_id forum_author forum_parent_id forum_name forum_moderated forum_description forum_attachments
Результат integer The forum ID on success.

saveMessage() публичный Метод

Saves the message.
public saveMessage ( array $info ) : mixed
$info array Array containing all the message data to save.
Результат mixed Message ID on success or PEAR_Error on failure.

setThreadLock() публичный Метод

public setThreadLock ( $message_id, $lock )

splitThread() публичный Метод

Splits a thread on message id.
public splitThread ( integer $message_id )
$message_id integer The ID of the message to split at.

updateBan() публичный Метод

Ban user on a specific forum.
public updateBan ( string $user, integer $forum_id = null, string $action = 'add' )
$user string Moderator username.
$forum_id integer Forum to add moderator to.
$action string Action to peform ('add' or 'delete').

updateModerator() публичный Метод

Updates forum moderators.
public updateModerator ( string $moderator, integer $forum_id = null, string $action = 'add' )
$moderator string Moderator username.
$forum_id integer Forum to add moderator to.
$action string Action to peform ('add' or 'delete').

Описание свойств

$_cache защищенное свойство

Cache object
protected Horde_Cache $_cache
Результат Horde_Cache

$_charset защищенное свойство

Charset
protected string $_charset
Результат string

$_db защищенное свойство

The database connection object.
protected Horde_Db_Adapter $_db
Результат Horde_Db_Adapter

$_forum публичное свойство

Current forum data
public array $_forum
Результат array

$_forum_id публичное свойство

Current forum ID
public string $_forum_id
Результат string

$_forums_table защищенное свойство

Scope theads table name
protected string $_forums_table
Результат string

$_scope защищенное свойство

The forums scope.
protected string $_scope
Результат string

$_threads_table защищенное свойство

Scope theads table name
protected string $_threads_table
Результат string