PHP Class Agora_Api, horde

This file defines Agora's external API interface. Other applications can interact with Agora through this API. 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.
Author: Marko Djukic ([email protected])
Author: Duck ([email protected])
Inheritance: extends Horde_Registry_Api
Datei anzeigen Open project: horde/horde

Public Methods

Method Description
addMessage ( string $scope, string $forum_name, string $callback, array $params = [] ) : mixed Allows other Horde apps to add/edit messages.
deleteForum ( string $scope, string $forum_name ) : boolean Allow other applications to delete forums. Used when an object that has been commented on has been deleted.
doComments ( string $scope, string $key, string $callback, $bodies = true, string $base_url = null, string $url = null, array $variables = null, string $template_file = false ) : mixed Allows other Horde apps to post messages.
getForumName ( string $scope, integer $forum_id ) : mixed Retrieve the name of a forum
getThreads ( string $forum_name, string $sort_by = 'message_timestamp', integer $sort_dir, boolean $bodies = false, string $scope = 'agora', string $base_url = null, string $from, string $count ) : array Returns all messages of a forum, in a threaded order.
getThreadsBatch ( array $forum_names, string $sort_by = 'message_timestamp', integer $sort_dir, boolean $bodies = false, string $scope = 'agora', string $base_url = null, string $from, string $count ) : array Returns all messages for the forums requested, in a threaded order.
getThreadsByForumOwner ( $owner, string $sort_by = 'message_timestamp', integer $sort_dir, boolean $bodies = false, string $scope = 'agora', string $from, string $count ) : array Returns all messages of a forum, in a threaded order.
listForums ( integer $forum_id, string $scope = null ) : array Get back a list of available forums.
moderateForm ( string $scope ) Prepare the moderate form
numMessages ( string $forum_name, string $scope = 'agora', integer $thread_id = null ) : integer Returns the number of messages in a forum.
numMessagesBatch ( array $forum_name, string $scope = 'agora', integer $thread_id = null ) : mixed Returns the number of messages for the requested forums.
postMessage ( string $scope, string $forum_name, string $callback, array $params = [], string $url = null, array $variables = null ) : mixed Allows other Horde apps to post messages.
prepareFormData ( string $scope, string $parent = false, array $info = [], string $callback = null ) Fill up a form data array.
removeMessage ( string $scope, string $forum_name, string $callback, array $params = [], array $variables = null ) : mixed Allows other Horde apps to remove messages.
renderThreads ( string $forum_name, boolean $bodies = false, string $scope = 'agora', string $base_url = null, string $template_file = false ) : string Returns all threads of a forum in a threaded view.
saveForum ( string $scope, string $parent, array $info ) Create or modify an agora forum.

Method Details

addMessage() public method

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.
public addMessage ( string $scope, string $forum_name, string $callback, array $params = [] ) : mixed
$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 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
return mixed Returns message id if the message was posted or PEAR_Error object on error

deleteForum() public method

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 ) : boolean
$scope string The Horde application that the forum belongs to.
$forum_name string The unique forum name to delete.
return boolean True on success.

doComments() public method

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.
public doComments ( string $scope, string $key, string $callback, $bodies = true, string $base_url = null, string $url = null, array $variables = null, string $template_file = false ) : mixed
$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.
$base_url string Base URL the edit/delete/reply links should point to.
$url string If specified, the form gets submitted to this URL instead of the current page.
$variables array A hash with all variables of a submitted form generated by this method.
$template_file string Template file to use.
return mixed array Returns either the rendered Horde_Form for comments and threads for posting/viewing a message or PEAR objects on error.

getForumName() public method

Retrieve the name of a forum
public getForumName ( string $scope, integer $forum_id ) : mixed
$scope string Scope which form belongs to
$forum_id integer The forum id to fetch the name for.
return mixed The forum name | Pear_Error

getThreads() public method

Returns all messages of a forum, in a threaded order.
public getThreads ( string $forum_name, string $sort_by = 'message_timestamp', integer $sort_dir, boolean $bodies = false, string $scope = 'agora', string $base_url = null, string $from, string $count ) : array
$forum_name string The unique name for the forum.
$sort_by string Return messages sorted by this property.
$sort_dir integer The direction by which to sort: 0 - ascending 1 - descending
$bodies boolean Whether to include message bodies in the view.
$scope string The application that the specified forum belongs to.
$base_url string 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 array All messages of the specified forum.

getThreadsBatch() public method

Returns all messages for the forums requested, in a threaded order.
public getThreadsBatch ( array $forum_names, string $sort_by = 'message_timestamp', integer $sort_dir, boolean $bodies = false, string $scope = 'agora', string $base_url = null, string $from, string $count ) : array
$forum_names array An array of unique forum names.
$sort_by string Return messages sorted by this property.
$sort_dir integer The direction by which to sort: 0 - ascending 1 - descending
$bodies boolean Whether to include message bodies in the view.
$scope string The application that the specified forum belongs to.
$base_url string 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 array An array of message arrays of the specified forum.

getThreadsByForumOwner() public method

Returns all messages of a forum, in a threaded order.
public getThreadsByForumOwner ( $owner, string $sort_by = 'message_timestamp', integer $sort_dir, boolean $bodies = false, string $scope = 'agora', string $from, string $count ) : array
$sort_by string Return messages sorted by this property.
$sort_dir integer The direction by which to sort: 0 - ascending 1 - descending
$bodies boolean Whether to include message bodies in the view.
$scope string 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 array All messages of the specified forum.

listForums() public method

Get back a list of available forums.
public listForums ( integer $forum_id, string $scope = null ) : array
$forum_id integer Supplying this parameter will return a list of child forums of the requested forum id.
$scope string If set, limit the forums to requested application.
return array The list of available forums.

moderateForm() public method

Prepare the moderate form
public moderateForm ( string $scope )
$scope string The Horde application that is saving this forum.

numMessages() public method

Returns the number of messages in a forum.
public numMessages ( string $forum_name, string $scope = 'agora', integer $thread_id = null ) : integer
$forum_name string The unique name for the forum.
$scope string The application that the specified forum belongs to.
$thread_id integer The thread to count, if not supplied it will count all messages
return integer The number of messages in the specified forum.

numMessagesBatch() public method

All requested forums must belong to the same scope.
public numMessagesBatch ( array $forum_name, string $scope = 'agora', integer $thread_id = null ) : mixed
$forum_name array An array of unique forum names.
$scope string The application that the specified forum belongs to.
$thread_id integer The thread to count, if not supplied it will count all messages
return mixed An array containing the message counts with the forum name as the key | PEAR_Error

postMessage() public method

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.
public postMessage ( string $scope, string $forum_name, string $callback, array $params = [], string $url = null, array $variables = null ) : mixed
$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 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 If specified, the form gets submitted to this URL instead of the current page.
$variables array A hash with all variables of a submitted form generated by this method.
return 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() public method

Fill up a form data array.
public prepareFormData ( string $scope, string $parent = false, array $info = [], string $callback = null )
$scope string The Horde application that is saving this forum.
$parent string The parent forum.
$info array The forum information to consisting of: forum_parent_id forum_name forum_description forum_moderated forum_attachments
$callback string A callback method of the specified application that gets called to make sure that posting to this forum is allowed.

removeMessage() public method

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.
public removeMessage ( string $scope, string $forum_name, string $callback, array $params = [], array $variables = null ) : mixed
$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 Any parameters for the forum message posting.
message_id        - An existing message to delete
$variables array A hash with all variables of a submitted form generated by this method.
return 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() public method

Returns all threads of a forum in a threaded view.
public renderThreads ( string $forum_name, boolean $bodies = false, string $scope = 'agora', string $base_url = null, string $template_file = false ) : string
$forum_name string The unique name for the forum.
$bodies boolean Whether to include message bodies in the view.
$scope string The application that the specified forum belongs to.
$base_url string An alternate link where edit/delete/reply links point to.
$template_file string Template file to use.
return string The HTML code of the thread view.

saveForum() public method

This is used for apps to create forums for their own use. They will not show up in the regular agora forum view.
public saveForum ( string $scope, string $parent, array $info )
$scope string The Horde application that is saving this forum.
$parent string The parent forum.
$info array The forum information to save