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

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.
 

Public Attributes

string $action
 
string null $alternatename
 user alternate name.
 
 $attachment
 
mixed $attachment_filemanager
 attachment.
 
string $body
 blog post body.
 
 $content
 
int $courseassoc
 course associated with the blog post.
 
 $courseid = 0
 
 $coursemoduleid = 0
 
 $created
 
string null $email
 user email address.
 
int $entryid
 attachment entry id.
 
string null $firstname
 user first name.
 
string null $firstnamephonetic
 user first name phonetic.
 
 $form
 
 $format = 1
 
 $groupid = 0
 
 $id
 
string null $imagealt
 user picture description.
 
 $lastmodified
 
string null $lastname
 user last name.
 
string null $lastnamephonetic
 user last name phonetic.
 
string null $middlename
 user middle name.
 
string $modassoc
 module associated with the blog post.
 
int $modid
 module instance id.
 
 $module = 'blog'
 
 $moduleid = 0
 
string null $picture
 user picture.
 
 $publishstate
 
 $rating = 0
 
StdClass $renderable
 Data needed to render the entry.
 
 $subject
 
string null $submitbutton
 submit button.
 
 $summary
 
array array $summary_editor
 summary editor.
 
string string $summaryformat
 summary format.
 
string $summarytrust
 
 $tags = array()
 
 $uniquehash = ''
 
 $userid
 
string null $useridalias
 user alias.
 
 $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: