comment_service.module in Services 7
Same filename and directory in other branches
@author Services Dev Team
Link commenting functionality to services module.
File
services/comment_service/comment_service.moduleView source
<?php
/**
* @author Services Dev Team
* @file
* Link commenting functionality to services module.
*/
/**
* Implementation of hook_help().
*/
function comment_service_help($path, $arg) {
switch ($path) {
case 'admin/help#services_comment':
return t('<p>Provides comment methods to services applications. Requires services.module.</p>');
case 'admin/modules#description':
return t('Provides comment methods to services applications. Requires services.module.');
}
}
/**
* Implementation of hook_perm().
*/
function comment_service_perm() {
return array(
'access comments from remote',
'save comments from remote',
);
}
/**
* Implementation of hook_service().
*/
function comment_service_service() {
return array(
// comment.save
array(
'#method' => 'comment.save',
'#callback' => 'comment_service_save',
'#access arguments' => array(
'save comments from remote',
),
'#file' => array(
'file' => 'inc',
'module' => 'comment_service',
),
'#args' => array(
array(
'#name' => 'comment',
'#type' => 'struct',
'#description' => t('A comment object.'),
),
),
'#return' => 'int',
'#help' => t('This method adds a comment to a node and returns a comment id. If the comment object contains a numeric "cid", then the comment will be updated. Required fields in the comment object: nid, comment. Optional fields: cid (comment id), pid (parent comment), subject, mail, homepage'),
),
// comment.loadNodeComments
array(
'#method' => 'comment.loadNodeComments',
'#callback' => 'comment_service_load_node_comments',
'#access arguments' => array(
'access comments from remote',
),
'#file' => array(
'file' => 'inc',
'module' => 'comment_service',
),
'#args' => array(
array(
'#name' => 'nid',
'#type' => 'int',
'#description' => t('A node id.'),
),
array(
'#name' => 'count',
'#type' => 'int',
'#description' => t('Number of comments to load.'),
),
array(
'#name' => 'start',
'#type' => 'int',
'#description' => t('If count is set to non-zero value, You can pass also non-zero value for start. For example to get comments from 5 to 15, pass count=10 and start=5.'),
),
),
'#return' => 'array',
'#help' => t('This method returns all or part of the comments on a given node.'),
),
// comment.load
array(
'#method' => 'comment.load',
'#callback' => 'comment_service_load',
'#access arguments' => array(
'access comments from remote',
),
'#file' => array(
'file' => 'inc',
'module' => 'comment_service',
),
'#args' => array(
array(
'#name' => 'cid',
'#type' => 'int',
'#description' => t('A comment id.'),
),
),
'#return' => 'array',
'#help' => t('This method returns a single comment object.'),
),
// node.comments.countAll
array(
'#method' => 'comment.countAll',
'#callback' => 'comment_service_node_comments_count_all',
'#access arguments' => array(
'access comments from remote',
),
'#file' => array(
'file' => 'inc',
'module' => 'comment_service',
),
'#args' => array(
array(
'#name' => 'nid',
'#type' => 'int',
'#description' => t('A node id.'),
),
),
'#return' => 'int',
'#help' => t('This method returns the number of comments on a given node.'),
),
// node.comments.countNew
array(
'#method' => 'comment.countNew',
'#callback' => 'comment_service_node_comments_count_new',
'#access arguments' => array(
'access comments from remote',
),
'#file' => array(
'file' => 'inc',
'module' => 'comment_service',
),
'#args' => array(
array(
'#name' => 'nid',
'#type' => 'int',
'#description' => t('A node id'),
),
array(
'#name' => 'since',
'#type' => 'int',
'#optional' => TRUE,
'#description' => t('Time to count from (defaults to time of last user acces to node).'),
),
),
'#return' => 'int',
'#help' => t('This method returns the number of new comments on a given node since a given timestamp.'),
),
);
}
Functions
Name | Description |
---|---|
comment_service_help | Implementation of hook_help(). |
comment_service_perm | Implementation of hook_perm(). |
comment_service_service | Implementation of hook_service(). |