Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
comment

Functions

 blog_comment_permissions ($commentparam)
 Running addtional permission check on plugin, for example, plugins may have switch to turn on/off comments option, this callback will affect UI display, not like pluginname_comment_validate only throw exceptions.
 
 blog_comment_validate ($commentparam)
 Validate comment parameter before perform other comments actions.
 
 blog_delete_external_entries ($externalblog)
 Given an external blog object, deletes all related blog entries from the post table.
 
 blog_get_all_options (moodle_page $page, stdClass $userid=null)
 This function gets all of the options available for the current user in respect to blogs.
 
 blog_get_associated_count ($courseid, $cmid=null)
 Shortcut function for getting a count of blog entries associated with a course or a module.
 
 blog_get_headers ($courseid=null, $groupid=null, $userid=null, $tagid=null, $tag=null, $modid=null, $entryid=null, $search=null)
 This function encapsulates all the logic behind the complex navigation, titles and headings of the blog listing page, depending on URL params.
 
 blog_get_options_for_course (stdClass $course, stdClass $user=null)
 Get the blog options that relate to the given course for the given user.
 
 blog_get_options_for_module ($module, $user=null)
 Get the blog options relating to the given module for the given user.
 
 blog_get_options_for_user (stdClass $user=null)
 Get all of the blog options that relate to the passed user.
 
 blog_get_tagged_posts ($tag, $exclusivemode=false, $fromctx=0, $ctx=0, $rec=true, $page=0)
 Returns posts tagged with a specified tag.
 
 blog_is_enabled_for_user ()
 This function checks that blogs are enabled, and that the user can see blogs at all.
 
 blog_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types.
 
 blog_remove_associations_for_course ($courseid)
 remove all associations for the blog entries of a particular course
 
 blog_remove_associations_for_module ($modcontextid)
 Remove module associated blogs and blog tag instances.
 
 blog_remove_associations_for_user ($userid)
 remove all associations for the blog entries of a particular user
 
 blog_sync_external_entries ($externalblog)
 Given a record in the {blog_external} table, checks the blog's URL for new entries not yet copied into Moodle.
 
 blog_user_can_edit_entry ($blogentry)
 User can edit a blog entry if this is their own blog entry and they have the capability moodle/blog:create, or if they have the capability moodle/blog:manageentries.
 
 blog_user_can_view_user_entry ($targetuserid, $blogentry=null)
 Checks to see if a user can view the blogs of another user.
 
 blog_validate_access ($courseid, $modid, $groupid, $entryid, $userid)
 Validate the access to a blog.
 
 core_blog_myprofile_navigation (core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course)
 Add nodes to myprofile page.
 

Detailed Description

Function Documentation

◆ blog_comment_permissions()

blog_comment_permissions ( $commentparam)

Running addtional permission check on plugin, for example, plugins may have switch to turn on/off comments option, this callback will affect UI display, not like pluginname_comment_validate only throw exceptions.

blog_comment_validate will be called before viewing/adding/deleting comment, so don't repeat checks. Capability check has been done in comment->check_permissions(), we don't need to do it again here.

Parameters
stdClass$commentparam{ context => context the context object courseid => int course id cm => stdClass course module object commentarea => string comment area itemid => int itemid }
Return values
array

◆ blog_comment_validate()

blog_comment_validate ( $commentparam)

Validate comment parameter before perform other comments actions.

Parameters
stdClass$comment{ context => context the context object courseid => int course id cm => stdClass course module object commentarea => string comment area itemid => int itemid }
Return values
boolean

◆ blog_delete_external_entries()

blog_delete_external_entries ( $externalblog)

Given an external blog object, deletes all related blog entries from the post table.

NOTE: The external blog's id is saved as post.content, a field that is not oterhwise used by blog entries.

Parameters
object$externablog

◆ blog_get_all_options()

blog_get_all_options ( moodle_page $page,
stdClass $userid = null )

This function gets all of the options available for the current user in respect to blogs.

It loads the following if applicable:

Parameters
moodle_page$pageThe page to load for (normally $PAGE)
stdClass$useridLoad for a specific user
Return values
arrayAn array of options organised by type.

◆ blog_get_associated_count()

blog_get_associated_count ( $courseid,
$cmid = null )

Shortcut function for getting a count of blog entries associated with a course or a module.

Parameters
int$courseidThe ID of the course
int$cmidThe ID of the course_modules
Return values
stringThe number of associated entries

◆ blog_get_headers()

blog_get_headers ( $courseid = null,
$groupid = null,
$userid = null,
$tagid = null,
$tag = null,
$modid = null,
$entryid = null,
$search = null )

This function encapsulates all the logic behind the complex navigation, titles and headings of the blog listing page, depending on URL params.

It looks at URL params and at the current context level. It builds and returns an array containing:

  1. heading: The heading displayed above the blog entries
  2. stradd: The text to be used as the "Add entry" link
  3. strview: The text to be used as the "View entries" link
  4. url: The moodle_url object used as the base for add and view links
  5. filters: An array of parameters used to filter blog listings. Used by index.php and the Recent blogs block

All other variables are set directly in $PAGE

It uses the current URL to build these variables. A number of mutually exclusive use cases are used to structure this function.

Parameters
int$courseidcourse id the the blog is associated to (can be null).
int$groupidgroup id to filter blogs I can see (can be null)
int$useridblog author id (can be null)
int$tagidtag id to filter (can be null)
string$tagtag name to filter (can be null)
int$modidmodule id the blog is associated to (can be null).
int$entryidblog entry id to filter(can be null)
string$searchstring to search (can be null)
Return values
array

◆ blog_get_options_for_course()

blog_get_options_for_course ( stdClass $course,
stdClass $user = null )

Get the blog options that relate to the given course for the given user.

@staticvar array $courseoptions A cache so we can save regenerating multiple times

Parameters
stdClass$courseThe course to load options for
stdClass$userThe user to load options for null == current user
Return values
arrayThe array of options

◆ blog_get_options_for_module()

blog_get_options_for_module ( $module,
$user = null )

Get the blog options relating to the given module for the given user.

@staticvar array $moduleoptions Cache

Parameters
stdClass | cm_info$moduleThe module to get options for
stdClass$userThe user to get options for null == currentuser
Return values
array

◆ blog_get_options_for_user()

blog_get_options_for_user ( stdClass $user = null)

Get all of the blog options that relate to the passed user.

If no user is passed the current user is assumed.

@staticvar array $useroptions Cache so we don't have to regenerate multiple times

Parameters
stdClass$user
Return values
arrayThe array of options for the requested user

◆ blog_get_tagged_posts()

blog_get_tagged_posts ( $tag,
$exclusivemode = false,
$fromctx = 0,
$ctx = 0,
$rec = true,
$page = 0 )

Returns posts tagged with a specified tag.

Parameters
core_tag_tag$tag
bool$exclusivemodeif set to true it means that no other entities tagged with this tag are displayed on the page and the per-page limit may be bigger
int$fromctxcontext id where the link was displayed, may be used by callbacks to display items in the same context first
int$ctxcontext id where to search for records
bool$recsearch in subcontexts as well
int$page0-based number of page being displayed
Return values
core_tag\output\tagindex

◆ blog_is_enabled_for_user()

blog_is_enabled_for_user ( )

This function checks that blogs are enabled, and that the user can see blogs at all.

Return values
bool

◆ blog_page_type_list()

blog_page_type_list ( $pagetype,
$parentcontext,
$currentcontext )

Return a list of page types.

Parameters
string$pagetypecurrent page type
stdClass$parentcontextBlock's parent context
stdClass$currentcontextCurrent context of block

◆ blog_remove_associations_for_course()

blog_remove_associations_for_course ( $courseid)

remove all associations for the blog entries of a particular course

Parameters
intcourseid - id of user whose blog associations will be deleted

◆ blog_remove_associations_for_module()

blog_remove_associations_for_module ( $modcontextid)

Remove module associated blogs and blog tag instances.

Parameters
int$modcontextidModule context ID.

◆ blog_remove_associations_for_user()

blog_remove_associations_for_user ( $userid)

remove all associations for the blog entries of a particular user

Parameters
intuserid - id of user whose blog associations will be deleted

◆ blog_sync_external_entries()

blog_sync_external_entries ( $externalblog)

Given a record in the {blog_external} table, checks the blog's URL for new entries not yet copied into Moodle.

Also attempts to identify and remove deleted blog entries

Parameters
object$externalblog
Return values
booleanFalse if the Feed is invalid

◆ blog_user_can_edit_entry()

blog_user_can_edit_entry ( $blogentry)

User can edit a blog entry if this is their own blog entry and they have the capability moodle/blog:create, or if they have the capability moodle/blog:manageentries.

This also applies to deleting of entries.

◆ blog_user_can_view_user_entry()

blog_user_can_view_user_entry ( $targetuserid,
$blogentry = null )

Checks to see if a user can view the blogs of another user.

Only blog level is checked here, the capabilities are enforced in blog/index.php

◆ blog_validate_access()

blog_validate_access ( $courseid,
$modid,
$groupid,
$entryid,
$userid )

Validate the access to a blog.

Parameters
int$courseidcourse id the the blog is associated to (can be null).
int$modidmodule id the blog is associated to (can be null).
int$groupidgroup id to filter blogs I can see (can be null)
int$entryidblog entry id (can be null)
int$useridblog author id (can be null)
Return values
arraywith the calculated course and id
Since
Moodle 3.6

◆ core_blog_myprofile_navigation()

core_blog_myprofile_navigation ( core_user\output\myprofile\tree $tree,
$user,
$iscurrentuser,
$course )

Add nodes to myprofile page.

Parameters
core_user\output\myprofile\tree$treeTree object
stdClass$useruser object
bool$iscurrentuser
stdClass$courseCourse object
Return values
bool