Overview

Packages

  • Agora
  • None

Classes

  • Agora
  • Agora_Api
  • Agora_Driver
  • Agora_Driver_SplitSql
  • Agora_Driver_Sql
  • Agora_Exception
  • Agora_Factory_Driver
  • Agora_Form_Forum
  • Agora_Form_Message
  • Agora_Form_Search
  • Agora_View
  • Horde_Form_Renderer_MessageForm
  • Overview
  • Package
  • Class
  • Tree

Class Agora_Driver

Agora_Driver:: provides the functions to access both threads and individual messages.

Copyright 2003-2012 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.

Direct known subclasses

Agora_Driver_SplitSql, Agora_Driver_Sql
Package: Agora
Author: Marko Djukic marko@oblo.com
Author: Jan Schneider jan@horde.org
Author: Duck duck@obala.net
Located at Driver.php
Methods summary
public
# __construct( mixed $scope, mixed $params )

Constructor

Constructor

public boolean
# allowAttachments( )

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

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

Returns

boolean
Whether attachments allowed or not.
public mixed
# saveMessage( array $info )

Saves the message.

Saves the message.

Parameters

$info
Array containing all the message data to save.

Returns

mixed
Message ID on success or PEAR_Error on failure.

Throws

Agora_Exception
public
# moveThread( integer $thread_id, integer $forum_id )

Moves a thread to another forum.

Moves a thread to another forum.

Parameters

$thread_id
The ID of the thread to move.
$forum_id
The ID of the destination forum.

Throws

Agora_Exception
public
# splitThread( integer $message_id )

Splits a thread on message id.

Splits a thread on message id.

Parameters

$message_id
The ID of the message to split at.

Throws

Agora_Exception
public
# mergeThread( integer $thread_from, integer $message_id )

Merges two threads.

Merges two threads.

Parameters

$thread_from
$thread_id The ID of the thread to merge.
$message_id
The ID of the message to merge to.

Throws

Agora_Exception
public
# getMessage( integer $message_id )

Fetches a message.

Fetches a message.

Parameters

$message_id
The ID of the message to fetch.

Throws

Horde_Exception_NotFound
Agora_Exception
public array
# replyMessage( mixed $message )

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

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

Parameters

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

Returns

array
A hash with all relevant information.

Throws

Horde_Exception_NotFound
Agora_Exception
public string
# deleteMessage( integer $message_id )

Deletes a message and all replies.

Deletes a message and all replies.

Parameters

$message_id
The ID of the message to delete.

Returns

string
Thread ID on success.

Throws

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

Increments or decrements a forum's message count.

Increments or decrements a forum's message count.

Parameters

$forum_id
Forum to update
$type
What to increment message, thread or view.
$diff
<p>Incremental or decremental step, either a positive or negative integer, or a plus or minus sign.</p>
public
# deleteThread( integer $thread_id = 0 )

Deletes an entire message thread.

Deletes an entire message thread.

Parameters

$thread_id
<p>The ID of the thread to delete. If not specified will delete all the threads for the current forum.</p>

Throws

Agora_Exception
public
# getThreads( integer $thread_root = 0, boolean $all_levels = false, string $sort_by = 'message_timestamp', integer $sort_dir = 0, 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.

Returns a list of threads.

Parameters

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

Formats a message body.

Formats a message body.

Parameters

$body
Text to format.
public
# isHot( mixed $views, mixed $last_post )

Returns true if the message is hot.

Returns true if the message is hot.

public
# isNew( mixed $thread_id, mixed $last_post )

Returns true, has new posts since user last visit

Returns true, has new posts since user last visit

public
# 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.

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

$sort_by
The column by which to sort.
$sort_dir
<p>The direction by which to sort: 0 - ascending 1 - descending</p>

Throws

Agora_Exception
public
# getBanned( )

Get banned users from the current forum

Get banned users from the current forum

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

Ban user on a specific forum.

Ban user on a specific forum.

Parameters

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

Updates forum moderators.

Updates forum moderators.

Parameters

$moderator
Moderator username.
$forum_id
Forum to add moderator to.
$action
Action to peform ('add' or 'delete').

Throws

Agora_Exception
public
# moderate( string $action, array $ids )

Approves one or more ids.

Approves one or more ids.

Parameters

$action
Whether to 'approve' or 'delete' messages.
$ids
Array of message IDs.

Throws

Agora_Exception
public integer
# countThreads( integer $thread_root = 0 )

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

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

Parameters

$thread_root
Thread to count.

Returns

integer

The number of messages in thread or PEAR_Error on failure.

public integer
# countMessages( )

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

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.

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

Returns a table showing the specified message list.

Returns a table showing the specified message list.

Parameters

$threads
<p>A hash with the thread messages as returned by <code><a href="class-Agora_Driver.html#_getThreads">Agora_Driver::getThreads()</a></code>.</p>
$col_headers
A hash with the column headers.
$bodies
Display the message bodies?
$template_file
Template to use.

Returns

string
The rendered message table.
public
# getThreadRoot( mixed $message_id )

Throws

Agora_Exception
public
# setThreadLock( mixed $message_id, mixed $lock )
public boolean
# isThreadLocked( mixed $message_id )

Returns

boolean
public
# getThreadActions( )
public
# getForm( mixed $vars, mixed $title, mixed $editing = false, mixed $new_forum = false )
public string
# dateFormat( integer $timestamp )

Formats time according to user preferences.

Formats time according to user preferences.

Parameters

$timestamp
Message timestamp.

Returns

string
Formatted date.
public boolean
# logView( mixed $thread_id )

Logs a message view.

Logs a message view.

Returns

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

Throws

Agora_Exception
public
# getAttachmentLink( mixed $message_id )

Constructs message attachments link.

Constructs message attachments link.

Throws

Agora_Exception
public string
# formatSize( integer $filesize )

Formats file size.

Formats file size.

Parameters

$filesize

Returns

string
Formatted filesize.
public array
# getForum( integer $forum_id = 0 )

Fetches a forum data.

Fetches a forum data.

Parameters

$forum_id
The ID of the forum to fetch.

Returns

array
The forum hash or a PEAR_Error on failure.

Throws

Horde_Exception_NotFound
Agora_Exception
public
# countForums( )

Returns the number of forums.

Returns the number of forums.

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

Fetches a list of forums.

Fetches a list of forums.

Parameters

$root_forum
The first level forum.
$formatted
Whether to return the list formatted or raw.
$sort_by
The column to sort by.
$sort_dir
<p>Sort direction, 0 = ascending, 1 = descending.</p>
$add_scope
<p>Add parent forum if forum for another scopelication.</p>
$from
The forum to start listing at.
$count
The number of forums to return.

Returns

mixed
An array of forums or PEAR_Error on failure.

Throws

Agora_Exception
public array
# getBareForums( )

Get forums ids and titles

Get forums ids and titles

Returns

array
An array of forums and form names.
public integer
# newForum( string $forum_name, string $owner )

Creates a new forum.

Creates a new forum.

Parameters

$forum_name
Forum name.
$owner
$forum_owner Forum owner.

Returns

integer
ID of the new generated forum.

Throws

Agora_Exception
public integer
# saveForum( array $info )

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

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

Parameters

$info
<p>The forum information to save consisting of: forum_id forum_author forum_parent_id forum_name forum_moderated forum_description forum_attachments</p>

Returns

integer
The forum ID on success.

Throws

Agora_Exception
public boolean
# deleteForum( integer $forum_id )

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

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

Parameters

$forum_id
The ID of the forum to delete.

Returns

boolean
True on success.

Throws

Agora_Exception
public array
# search( array $filter, string $sort_by = 'message_subject', integer $sort_dir = 0, string $from = 0, string $count = 0 )

Searches forums for matching threads or posts.

Searches forums for matching threads or posts.

Parameters

$filter
<p>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.</p>
$sort_by
The column by which to sort.
$sort_dir
<p>The direction by which to sort: 0 - ascending 1 - descending</p>
$from
The thread to start listing at.
$count
The number of threads to return.

Returns

array

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

Throws

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

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

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

Parameters

$perm
The permission level needed for access.
$forum_id
Forum to check permissions for.
$scope
Application scope to use.

Returns

boolean
True if the user has the specified permissions.
public mixed
# convertFromDriver( mixed $value )

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

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

Parameters

$value
A value to convert.

Returns

mixed
The converted value.
public mixed
# convertToDriver( mixed $value )

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

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

Parameters

$value
A value to convert.

Returns

mixed
The converted value.
Properties summary
public array $_forum

Current forum data

Current forum data

#
public string $_forum_id

Current forum ID

Current forum ID

#
API documentation generated by ApiGen