Documentation

Agora_Api extends Horde_Registry_Api
in package

Agora external API interface.

This file defines Agora's external API interface. Other applications can interact with Agora through this API.

Copyright 2003-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.

Tags
author

Marko Djukic marko@oblo.com

author

Duck duck@obala.net

Table of Contents

addMessage()  : mixed
Allows other Horde apps to add/edit messages.
deleteForum()  : bool
Allow other applications to delete forums. Used when an object that has been commented on has been deleted.
doComments()  : mixed
Allows other Horde apps to post messages.
getForumName()  : mixed
Retrieve the name of a forum
getThreads()  : array<string|int, mixed>
Returns all messages of a forum, in a threaded order.
getThreadsBatch()  : array<string|int, mixed>
Returns all messages for the forums requested, in a threaded order.
getThreadsByForumOwner()  : array<string|int, mixed>
Returns all messages of a forum, in a threaded order.
listForums()  : array<string|int, mixed>
Get back a list of available forums.
moderateForm()  : mixed
Prepare the moderate form
numMessages()  : int
Returns the number of messages in a forum.
numMessagesBatch()  : mixed
Returns the number of messages for the requested forums.
postMessage()  : mixed
Allows other Horde apps to post messages.
prepareFormData()  : mixed
Fill up a form data array.
removeMessage()  : mixed
Allows other Horde apps to remove messages.
renderThreads()  : string
Returns all threads of a forum in a threaded view.
saveForum()  : mixed
Create or modify an agora forum.

Methods

addMessage()

Allows other Horde apps to add/edit messages.

public addMessage(string $scope, string $forum_name, string $callback[, array<string|int, mixed> $params = array() ]) : mixed

The forum name is constructed by just the $forum_name variable under the data root 'agora.forums.'. It is up to the apps themselves to make sure that the forum name is unique.

If the forum does not exist, it will be automatically created by Agora.

Parameters
$scope : string

The application which is posting this message.

$forum_name : string

The unique name for the forum.

$callback : string

A callback method of the specified application that gets called to make sure that posting to this forum is allowed.

$params : array<string|int, mixed> = array()

Any parameters for the forum message posting.

message_id        - An existing message to edit
message_parent_id - The ID of the parent message
message_body      - Message body
Tags
access

private

Return values
mixed

Returns message id if the message was posted or PEAR_Error object on error

deleteForum()

Allow other applications to delete forums. Used when an object that has been commented on has been deleted.

public deleteForum(string $scope, string $forum_name) : bool
Parameters
$scope : string

The Horde application that the forum belongs to.

$forum_name : string

The unique forum name to delete.

Return values
bool

True on success.

doComments()

Allows other Horde apps to post messages.

public doComments(string $scope, string $key, string $callback[, mixed $bodies = true ][, string $base_url = null ][, string $url = null ][, array<string|int, mixed> $variables = null ][, string $template_file = false ]) : mixed

In most apps we use the same code to make comments possible. This function does most of that. Allow comments to be added to any app. The app itself should check if the agora api is present, determine a key and call this function before app::menu is called (before any output has started. At the end of its output it can print the array returned to show the comments.

Parameters
$scope : string

The application which is posting this message.

$key : string

Unique key from the object (picture etc we're viewing. It will be used as the forum name.

$callback : string

A callback method of the specified application that gets called to make sure that posting to this forum is allowed.

$bodies : mixed = true
$base_url : string = null

Base URL the edit/delete/reply links should point to.

$url : string = null

If specified, the form gets submitted to this URL instead of the current page.

$variables : array<string|int, mixed> = null

A hash with all variables of a submitted form generated by this method.

$template_file : string = false

Template file to use.

Tags
access

private

Return values
mixed

array Returns either the rendered Horde_Form for comments and threads for posting/viewing a message or PEAR objects on error.

getForumName()

Retrieve the name of a forum

public getForumName(string $scope, int $forum_id) : mixed
Parameters
$scope : string

Scope which form belongs to

$forum_id : int

The forum id to fetch the name for.

Return values
mixed

The forum name | Pear_Error

getThreads()

Returns all messages of a forum, in a threaded order.

public getThreads(string $forum_name[, string $sort_by = 'message_timestamp' ], int $sort_dir[, bool $bodies = false ][, string $scope = 'agora' ][, string $base_url = null ], string $from, string $count) : array<string|int, mixed>
Parameters
$forum_name : string

The unique name for the forum.

$sort_by : string = 'message_timestamp'

Return messages sorted by this property.

$sort_dir : int

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

$bodies : bool = false

Whether to include message bodies in the view.

$scope : string = 'agora'

The application that the specified forum belongs to.

$base_url : string = null

An alternate link where edit/delete/reply links point to.

$from : string

The thread to begin listing at.

$count : string

The number of threads to return.

Return values
array<string|int, mixed>

All messages of the specified forum.

getThreadsBatch()

Returns all messages for the forums requested, in a threaded order.

public getThreadsBatch(array<string|int, mixed> $forum_names[, string $sort_by = 'message_timestamp' ], int $sort_dir[, bool $bodies = false ][, string $scope = 'agora' ][, string $base_url = null ], string $from, string $count) : array<string|int, mixed>
Parameters
$forum_names : array<string|int, mixed>

An array of unique forum names.

$sort_by : string = 'message_timestamp'

Return messages sorted by this property.

$sort_dir : int

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

$bodies : bool = false

Whether to include message bodies in the view.

$scope : string = 'agora'

The application that the specified forum belongs to.

$base_url : string = null

An alternate link where edit/delete/reply links point to.

$from : string

The thread to begin listing at.

$count : string

The number of threads to return.

Return values
array<string|int, mixed>

An array of message arrays of the specified forum.

getThreadsByForumOwner()

Returns all messages of a forum, in a threaded order.

public getThreadsByForumOwner(mixed $owner[, string $sort_by = 'message_timestamp' ], int $sort_dir[, bool $bodies = false ][, string $scope = 'agora' ], string $from, string $count) : array<string|int, mixed>
Parameters
$owner : mixed
$sort_by : string = 'message_timestamp'

Return messages sorted by this property.

$sort_dir : int

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

$bodies : bool = false

Whether to include message bodies in the view.

$scope : string = 'agora'

The application that the specified forum belongs to.

$from : string

The thread to begin listing at.

$count : string

The number of threads to return.

Return values
array<string|int, mixed>

All messages of the specified forum.

listForums()

Get back a list of available forums.

public listForums(int $forum_id[, string $scope = null ]) : array<string|int, mixed>
Parameters
$forum_id : int

Supplying this parameter will return a list of child forums of the requested forum id.

$scope : string = null

If set, limit the forums to requested application.

Return values
array<string|int, mixed>

The list of available forums.

moderateForm()

Prepare the moderate form

public moderateForm(string $scope) : mixed
Parameters
$scope : string

The Horde application that is saving this forum.

Return values
mixed

numMessages()

Returns the number of messages in a forum.

public numMessages(string $forum_name[, string $scope = 'agora' ][, int $thread_id = null ]) : int
Parameters
$forum_name : string

The unique name for the forum.

$scope : string = 'agora'

The application that the specified forum belongs to.

$thread_id : int = null

The thread to count, if not supplied it will count all messages

Return values
int

The number of messages in the specified forum.

numMessagesBatch()

Returns the number of messages for the requested forums.

public numMessagesBatch(array<string|int, mixed> $forum_name[, string $scope = 'agora' ][, int $thread_id = null ]) : mixed

All requested forums must belong to the same scope.

Parameters
$forum_name : array<string|int, mixed>

An array of unique forum names.

$scope : string = 'agora'

The application that the specified forum belongs to.

$thread_id : int = null

The thread to count, if not supplied it will count all messages

Return values
mixed

An array containing the message counts with the forum name as the key | PEAR_Error

postMessage()

Allows other Horde apps to post messages.

public postMessage(string $scope, string $forum_name, string $callback[, array<string|int, mixed> $params = array() ][, string $url = null ][, array<string|int, mixed> $variables = null ]) : mixed

The forum name is constructed by just the $forum_name variable under the data root 'agora.forums.'. It is up to the apps themselves to make sure that the forum name is unique.

If the forum does not exist, it will be automatically created by Agora.

Parameters
$scope : string

The application which is posting this message.

$forum_name : string

The unique name for the forum.

$callback : string

A callback method of the specified application that gets called to make sure that posting to this forum is allowed.

$params : array<string|int, mixed> = array()

Any parameters for the forum message posting.

message_id        - An existing message to edit
message_parent_id - The ID of the parent message
title             - Posting title
$url : string = null

If specified, the form gets submitted to this URL instead of the current page.

$variables : array<string|int, mixed> = null

A hash with all variables of a submitted form generated by this method.

Tags
access

private

Return values
mixed

Returns either the rendered Horde_Form for posting a message or PEAR_Error object on error, or true in case of a successful post.

prepareFormData()

Fill up a form data array.

public prepareFormData(string $scope[, string $parent = false ][, array<string|int, mixed> $info = array() ][, string $callback = null ]) : mixed
Parameters
$scope : string

The Horde application that is saving this forum.

$parent : string = false

The parent forum.

$info : array<string|int, mixed> = array()

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

$callback : string = null

A callback method of the specified application that gets called to make sure that posting to this forum is allowed.

Return values
mixed

removeMessage()

Allows other Horde apps to remove messages.

public removeMessage(string $scope, string $forum_name, string $callback[, array<string|int, mixed> $params = array() ][, array<string|int, mixed> $variables = null ]) : mixed

The forum name is constructed by just the $forum_name variable under the data root 'agora.forums.'. It is up to the apps themselves to make sure that the forum name is unique.

Parameters
$scope : string

The application which is posting this message.

$forum_name : string

The unique name for the forum.

$callback : string

A callback method of the specified application that gets called to make sure that posting to this forum is allowed.

$params : array<string|int, mixed> = array()

Any parameters for the forum message posting.

message_id        - An existing message to delete
$variables : array<string|int, mixed> = null

A hash with all variables of a submitted form generated by this method.

Tags
access

private

Return values
mixed

Returns either the rendered Horde_Form for posting a message or PEAR_Error object on error, or true in case of a successful post.

renderThreads()

Returns all threads of a forum in a threaded view.

public renderThreads(string $forum_name[, bool $bodies = false ][, string $scope = 'agora' ][, string $base_url = null ][, string $template_file = false ]) : string
Parameters
$forum_name : string

The unique name for the forum.

$bodies : bool = false

Whether to include message bodies in the view.

$scope : string = 'agora'

The application that the specified forum belongs to.

$base_url : string = null

An alternate link where edit/delete/reply links point to.

$template_file : string = false

Template file to use.

Return values
string

The HTML code of the thread view.

saveForum()

Create or modify an agora forum.

public saveForum(string $scope, string $parent, array<string|int, mixed> $info) : mixed

This is used for apps to create forums for their own use. They will not show up in the regular agora forum view.

Parameters
$scope : string

The Horde application that is saving this forum.

$parent : string

The parent forum.

$info : array<string|int, mixed>

The forum information to save

Return values
mixed

Search results