Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
blog_entry Class Reference

Blog_entry class. More...

Inheritance diagram for blog_entry:
renderable

Public Member Functions

 __construct ($id=null, $params=null, $form=null)
 Constructor. More...
 
 add ()
 Inserts this entry in the database. More...
 
 add_association ($contextid, $unused=null)
 Add a single association for a blog entry. More...
 
 add_associations ($unused=null)
 Function to add all context associations to an entry. More...
 
 can_user_edit ($userid=null)
 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. More...
 
 can_user_view ($targetuserid)
 Checks to see if a user can view the blogs of another user. More...
 
 delete ()
 Deletes this entry from the database. More...
 
 delete_attachments ()
 Deletes all the user files in the attachments area for an entry. More...
 
 edit ($params=array(), $form=null, $summaryoptions=array(), $attachmentoptions=array())
 Updates this entry in the database. More...
 
 get_attachments ()
 Gets the entry attachments list. More...
 
 prepare_render ()
 Gets the required data to print the entry.
 
 process_attachment ($form)
 Inserts this entry in the database. More...
 
 remove_associations ()
 remove all associations for a blog entry More...
 

Static Public Member Functions

static get_applicable_publish_states ()
 Use this function to retrieve a list of publish states available for the currently logged in user. More...
 

Public Attributes

 $attachment
 
 $content
 
 $courseid = 0
 
 $coursemoduleid = 0
 
 $created
 
 $form
 
 $format = 1
 
 $groupid = 0
 
 $id
 
 $lastmodified
 
 $module = 'blog'
 
 $moduleid = 0
 
 $publishstate
 
 $rating = 0
 
StdClass $renderable
 Data needed to render the entry.
 
 $subject
 
 $summary
 
 $tags = array()
 
 $uniquehash = ''
 
 $userid
 
 $usermodified
 

Detailed Description

Blog_entry class.

Represents an entry in a user's blog. Contains all methods for managing this entry. This class does not contain any HTML-generating code. See blog_listing sub-classes for such code. This class follows the Object Relational Mapping technique, its member variables being mapped to the fields of the post table.

@subpackage blog

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

blog_entry::__construct (   $id = null,
  $params = null,
  $form = null 
)

Constructor.

If given an id, will fetch the corresponding record from the DB.

Parameters
mixed$idorparamsA blog entry id if INT, or data for a new entry if array

Member Function Documentation

◆ add()

blog_entry::add ( )

Inserts this entry in the database.

Access control checks must be done by calling code. TODO Set the publishstate correctly

Return values
void

◆ add_association()

blog_entry::add_association (   $contextid,
  $unused = null 
)

Add a single association for a blog entry.

Parameters
int$contextid- id of context to associate with the blog entry.
string$unusedThis does nothing, do not use it.

◆ add_associations()

blog_entry::add_associations (   $unused = null)

Function to add all context associations to an entry.

Parameters
string$unusedThis does nothing, do not use it.

◆ can_user_edit()

blog_entry::can_user_edit (   $userid = null)

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.

Parameters
int$useridOptional. If not given, $USER is used
Return values
boolean

◆ can_user_view()

blog_entry::can_user_view (   $targetuserid)

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

Parameters
int$targetuseridID of the user we are checking
Return values
bool

◆ delete()

blog_entry::delete ( )

Deletes this entry from the database.

Access control checks must be done by calling code.

Return values
void

◆ delete_attachments()

blog_entry::delete_attachments ( )

Deletes all the user files in the attachments area for an entry.

Return values
void

◆ edit()

blog_entry::edit (   $params = array(),
  $form = null,
  $summaryoptions = array(),
  $attachmentoptions = array() 
)

Updates this entry in the database.

Access control checks must be done by calling code.

Parameters
array$paramsEntry parameters.
moodleform$formUsed for attachments.
array$summaryoptionsSummary options.
array$attachmentoptionsAttachment options.
Return values
void

◆ get_applicable_publish_states()

static blog_entry::get_applicable_publish_states ( )
static

Use this function to retrieve a list of publish states available for the currently logged in user.

Return values
arrayThis function returns an array ideal for sending to moodles' choose_from_menu function.

◆ get_attachments()

blog_entry::get_attachments ( )

Gets the entry attachments list.

Return values
arrayList of blog_entry_attachment instances

◆ process_attachment()

blog_entry::process_attachment (   $form)

Inserts this entry in the database.

Access control checks must be done by calling code.

Parameters
mform$formUsed for attachments
Return values
void

◆ remove_associations()

blog_entry::remove_associations ( )

remove all associations for a blog entry

Return values
void

The documentation for this class was generated from the following file: