Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Public Member Functions | |
__construct (stdClass $options) | |
Construct function of comment class, initialise class members. More... | |
moodle_database | add ($content, $format=FORMAT_MOODLE) |
Add a new comment. More... | |
can_delete ($comment) | |
Returns true if the user can delete this comment. More... | |
can_post () | |
Returns true if the user can add comments against this comment description. More... | |
can_view () | |
Returns true if the user is able to view comments. More... | |
moodle_database | count () |
Returns the number of comments associated with the details of this object. More... | |
delete ($comment) | |
Delete a comment. More... | |
get_autostart () | |
Return autostart. More... | |
get_cid () | |
Return the cid. More... | |
get_cm () | |
Returns the course module associated with the comment. More... | |
get_commentarea () | |
Returns the comment area associated with the commentarea. More... | |
get_comments ($page='', $sortdirection='DESC') | |
Return matched comments. More... | |
get_component () | |
Returns the component associated with the comment. More... | |
get_compontent () | |
Do not call! I am a deprecated method because of the typo in my name. More... | |
get_context () | |
Returns the context associated with the comment. More... | |
get_courseid () | |
Returns the course id associated with the comment. More... | |
get_displaycancel () | |
Return display cancel. More... | |
get_displaytotalcount () | |
Return display total count. More... | |
get_fullwidth () | |
Return fullwidth. More... | |
get_itemid () | |
Returns the item id associated with the comment. More... | |
get_linktext () | |
Return the link text. More... | |
moodle_page | get_nojslink (moodle_page $page=null) |
Gets a link for this page that will work with JS disabled. More... | |
get_notoggle () | |
Return no toggle. More... | |
stdClass | get_pagination ($page=0) |
Returns HTML to display a pagination bar. More... | |
get_template () | |
Return the template. More... | |
initialise_javascript (moodle_page $page) | |
Initialises the JavaScript that enchances the comment API. More... | |
output ($return=true) | |
Prepare comment code in html. More... | |
core_renderer | print_comment ($cmt, $nonjs=true) |
Returns an array containing comments in HTML format. More... | |
print_comments ($page=0, $return=true, $nonjs=true) | |
Print comments. More... | |
set_autostart ($newvalue=true) | |
Sets the value of the autostart option. More... | |
set_component ($component) | |
Sets the component. More... | |
set_displaycancel ($newvalue=true) | |
Sets the displaycancel option. More... | |
set_displaytotalcount ($newvalue=true) | |
Sets the displaytotalcount option. More... | |
set_fullwidth ($fullwidth=true) | |
Make the comments textarea fullwidth. More... | |
set_notoggle ($newvalue=true) | |
Sets the value of the notoggle option. More... | |
set_post_permission ($value) | |
Determines if the user can post a comment. More... | |
set_view_permission ($value) | |
Determines if the user can view the comment. More... | |
Static Public Member Functions | |
static | delete_comments ($param) |
delete by context, commentarea and itemid More... | |
static | init (moodle_page $page=null) |
Receive nonjs comment parameters. More... | |
static | reset_course_page_comments ($context) |
Delete page_comments in whole course, used by course reset. More... | |
Protected Member Functions | |
get_component_select_sql ($alias='') | |
Returns an SQL fragment and param for selecting on component. More... | |
validate ($params=array()) | |
Revoke validate callbacks. More... | |
comment::__construct | ( | stdClass | $options | ) |
Construct function of comment class, initialise class members.
stdClass | $options | { context => context context to use for the comment [required] component => string which plugin will comment being added to [required] itemid => int the id of the associated item (forum post, glossary item etc) [required] area => string comment area cm => stdClass course module course => course course object client_id => string an unique id to identify comment area autostart => boolean automatically expend comments showcount => boolean display the number of comments displaycancel => boolean display cancel button notoggle => boolean don't show/hide button linktext => string title of show/hide button } |
moodle_database comment::add | ( | $content, | |
$format = FORMAT_MOODLE |
|||
) |
Add a new comment.
$DB
string | $content | |
int | $format |
stdClass |
comment::can_delete | ( | $comment | ) |
Returns true if the user can delete this comment.
The user can delete comments if it is one they posted and they can still make posts, or they have the capability to delete comments.
A database call is avoided if a comment record is passed.
int | stdClass | $comment | The id of a comment, or a comment record. |
bool |
comment::can_post | ( | ) |
Returns true if the user can add comments against this comment description.
bool |
comment::can_view | ( | ) |
Returns true if the user is able to view comments.
bool |
moodle_database comment::count | ( | ) |
Returns the number of comments associated with the details of this object.
$DB
int |
comment::delete | ( | $comment | ) |
Delete a comment.
int | stdClass | $comment | The id of a comment, or a comment record. |
bool |
|
static |
delete by context, commentarea and itemid
stdClass | array | $param | { contextid => int the context in which the comments exist [required] commentarea => string the comment area [optional] itemid => int comment itemid [optional] } |
boolean |
comment::get_autostart | ( | ) |
Return autostart.
bool |
comment::get_cid | ( | ) |
Return the cid.
string |
comment::get_cm | ( | ) |
Returns the course module associated with the comment.
stdClass |
comment::get_commentarea | ( | ) |
Returns the comment area associated with the commentarea.
stdClass |
comment::get_comments | ( | $page = '' , |
|
$sortdirection = 'DESC' |
|||
) |
Return matched comments.
int | $page | |
str | $sortdirection | sort direction, ASC or DESC |
array |
comment::get_component | ( | ) |
Returns the component associated with the comment.
string |
|
protected |
Returns an SQL fragment and param for selecting on component.
string | $alias |
array |
comment::get_compontent | ( | ) |
Do not call! I am a deprecated method because of the typo in my name.
string |
comment::get_context | ( | ) |
Returns the context associated with the comment.
stdClass |
comment::get_courseid | ( | ) |
Returns the course id associated with the comment.
int |
comment::get_displaycancel | ( | ) |
Return display cancel.
bool |
comment::get_displaytotalcount | ( | ) |
Return display total count.
bool |
comment::get_fullwidth | ( | ) |
Return fullwidth.
bool |
comment::get_itemid | ( | ) |
Returns the item id associated with the comment.
int |
comment::get_linktext | ( | ) |
Return the link text.
string |
moodle_page comment::get_nojslink | ( | moodle_page | $page = null | ) |
Gets a link for this page that will work with JS disabled.
$PAGE
moodle_page | $page |
moodle_url |
comment::get_notoggle | ( | ) |
Return no toggle.
bool |
stdClass comment::get_pagination | ( | $page = 0 | ) |
Returns HTML to display a pagination bar.
$CFG @global core_renderer $OUTPUT
int | $page |
string |
comment::get_template | ( | ) |
Return the template.
string |
|
static |
Receive nonjs comment parameters.
moodle_page | $page | The page object to initialise comments within If not provided the global $PAGE is used |
comment::initialise_javascript | ( | moodle_page | $page | ) |
Initialises the JavaScript that enchances the comment API.
moodle_page | $page | The moodle page object that the JavaScript should be initialised for. |
comment::output | ( | $return = true | ) |
Prepare comment code in html.
boolean | $return |
string|void |
core_renderer comment::print_comment | ( | $cmt, | |
$nonjs = true |
|||
) |
Returns an array containing comments in HTML format.
$OUTPUT
stdClass | $cmt | { id => int comment id content => string comment content format => int comment text format timecreated => int comment's timecreated profileurl => string link to user profile fullname => comment author's full name avatar => string user's avatar delete => boolean does user have permission to delete comment? } |
bool | $nonjs |
array |
comment::print_comments | ( | $page = 0 , |
|
$return = true , |
|||
$nonjs = true |
|||
) |
Print comments.
int | $page | |
bool | $return | return comments list string or print it out |
bool | $nonjs | print nonjs comments list or not? |
string|void |
|
static |
Delete page_comments in whole course, used by course reset.
stdClass | $context | course context |
comment::set_autostart | ( | $newvalue = true | ) |
Sets the value of the autostart option.
If set to true then the comments will be loaded during page load. Normally this happens only once the user expands the comment section.
bool | $newvalue |
comment::set_component | ( | $component | ) |
Sets the component.
This method shouldn't be public, changing the component once it has been set potentially invalidates permission checks. A coding_error is now thrown if code attempts to change the component.
coding_exception | if you try to change the component after it has been set. |
string | $component |
comment::set_displaycancel | ( | $newvalue = true | ) |
Sets the displaycancel option.
If set to true then a cancel button will be shown when using the form to post comments.
bool | $newvalue |
comment::set_displaytotalcount | ( | $newvalue = true | ) |
Sets the displaytotalcount option.
If set to true then the total number of comments will be displayed when printing comments.
bool | $newvalue |
comment::set_fullwidth | ( | $fullwidth = true | ) |
Make the comments textarea fullwidth.
bool | $fullwidth |
comment::set_notoggle | ( | $newvalue = true | ) |
Sets the value of the notoggle option.
If set to true then the user will not be able to expand and collase the comment section.
bool | $newvalue |
comment::set_post_permission | ( | $value | ) |
Determines if the user can post a comment.
bool | $value |
comment::set_view_permission | ( | $value | ) |
Determines if the user can view the comment.
bool | $value |
|
protected |
Revoke validate callbacks.
stdClass | $params | addtionall parameters need to add to callbacks |