Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mod_forum\local\managers\capability Class Reference

Capability manager for the forum. More...

Public Member Functions

 __construct (forum_entity $forum, legacy_forum_data_mapper $forumdatamapper, legacy_discussion_data_mapper $discussiondatamapper, legacy_post_data_mapper $postdatamapper)
 Constructor. More...
 
 can_access_all_groups (stdClass $user)
 Can the user access all groups? More...
 
 can_access_group (stdClass $user, int $groupid)
 Can the user access the given group? More...
 
 can_create_discussions (stdClass $user, int $groupid=null)
 Can the user create discussions in this forum? More...
 
 can_delete_post (stdClass $user, discussion_entity $discussion, post_entity $post, bool $hasreplies=false)
 Can the user delete the post in this discussion? More...
 
 can_edit_post (stdClass $user, discussion_entity $discussion, post_entity $post)
 Can the user edit the post in this discussion? More...
 
 can_export_discussions (stdClass $user)
 Can the user export (see portfolios) discussions in this forum? More...
 
 can_export_forum (stdClass $user)
 Checks whether the user can export the whole forum (discussions and posts). More...
 
 can_export_post (stdClass $user, post_entity $post)
 Can the user export (see portfolios) the post in this discussion? More...
 
 can_favourite_discussion (stdClass $user)
 Can the user favourite the discussion. More...
 
 can_grade (stdClass $grader, stdClass $gradee=null)
 Check whether the supplied grader can grade the gradee. More...
 
 can_manage_forum (stdClass $user)
 Can the user manage this forum? More...
 
 can_manage_tags (stdClass $user)
 Can the user manage tags on the site? More...
 
 can_manually_control_post_read_status (stdClass $user)
 Can the user manually mark posts as read/unread in this forum? More...
 
 can_move_discussion (stdClass $user, discussion_entity $discussion)
 Can the user move the discussion in this forum? More...
 
 can_move_discussions (stdClass $user)
 Can the user move discussions in this forum? More...
 
 can_pin_discussion (stdClass $user, discussion_entity $discussion)
 Is the user pin the discussion? More...
 
 can_pin_discussions (stdClass $user)
 Can the user pin discussions in this forum? More...
 
 can_post_in_discussion (stdClass $user, discussion_entity $discussion)
 Can the user post in this discussion? More...
 
 can_post_to_my_groups (stdClass $user)
 Can the user post to their groups? More...
 
 can_reply_privately_to_post (stdClass $user, post_entity $post)
 Can the user reply privately to the specified post? More...
 
 can_reply_to_post (stdClass $user, discussion_entity $discussion, post_entity $post)
 Can the user reply to the post in this discussion? More...
 
 can_self_enrol (stdClass $user)
 Checks whether the user can self enrol into the course. More...
 
 can_split_discussions (stdClass $user)
 Can the user split discussions in this forum? More...
 
 can_split_post (stdClass $user, discussion_entity $discussion, post_entity $post)
 Can the user split the post in this discussion? More...
 
 can_subscribe_to_discussion (stdClass $user, discussion_entity $discussion)
 Can the user subscribe to the give discussion? More...
 
 can_subscribe_to_forum (stdClass $user)
 Can the user subscribe to this forum? More...
 
 can_view_any_private_reply (stdClass $user)
 Whether the user can view any private reply in the forum. More...
 
 can_view_discussion (stdClass $user, discussion_entity $discussion)
 Can the user view the content of a discussion? More...
 
 can_view_discussions (stdClass $user)
 Can the user view discussions in this forum? More...
 
 can_view_hidden_posts (stdClass $user)
 Can the user view hidden posts in this forum? More...
 
 can_view_participants (stdClass $user, discussion_entity $discussion)
 Can the user view the participants of this discussion? More...
 
 can_view_post (stdClass $user, discussion_entity $discussion, post_entity $post)
 Can the user view the content of the post in this discussion? More...
 
 can_view_post_shell (stdClass $user, post_entity $post)
 Can the user view the post at all? In some situations the user can view the shell of a post without being able to view its content. More...
 
 must_post_before_viewing_discussion (stdClass $user, discussion_entity $discussion)
 Is the user required to post in the discussion before they can view it? More...
 
 validate_delete_post (stdClass $user, discussion_entity $discussion, post_entity $post, bool $hasreplies=false)
 Verifies is the given user can delete a post. More...
 

Protected Member Functions

 get_context ()
 Get the context for this capability manager. More...
 
 get_discussion_record (discussion_entity $discussion)
 Get the legacy discussion record for the given discussion entity. More...
 
 get_forum ()
 Get the forum entity for this capability manager. More...
 
 get_forum_record ()
 Get the legacy forum record for this forum. More...
 
 get_post_record (post_entity $post)
 Get the legacy post record for the given post entity. More...
 

Protected Attributes

array $canviewpostcache = []
 $canviewpostcache Cache of discussion posts that can be viewed by a user.
 

Detailed Description

Capability manager for the forum.

Defines all the business rules for what a user can and can't do in the forum.

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

Constructor & Destructor Documentation

◆ __construct()

mod_forum\local\managers\capability::__construct ( forum_entity  $forum,
legacy_forum_data_mapper  $forumdatamapper,
legacy_discussion_data_mapper  $discussiondatamapper,
legacy_post_data_mapper  $postdatamapper 
)

Constructor.

Parameters
forum_entity$forumThe forum entity to manage capabilities for.
legacy_forum_data_mapper$forumdatamapperLegacy forum data mapper
legacy_discussion_data_mapper$discussiondatamapperLegacy discussion data mapper
legacy_post_data_mapper$postdatamapperLegacy post data mapper

Member Function Documentation

◆ can_access_all_groups()

mod_forum\local\managers\capability::can_access_all_groups ( stdClass  $user)

Can the user access all groups?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_access_group()

mod_forum\local\managers\capability::can_access_group ( stdClass  $user,
int  $groupid 
)

Can the user access the given group?

Parameters
stdClass$userThe user to check
int$groupidThe id of the group that the forum is set to
Return values
bool

◆ can_create_discussions()

mod_forum\local\managers\capability::can_create_discussions ( stdClass  $user,
int  $groupid = null 
)

Can the user create discussions in this forum?

Parameters
stdClass$userThe user to check
int | null$groupidThe current activity group id
Return values
bool

◆ can_delete_post()

mod_forum\local\managers\capability::can_delete_post ( stdClass  $user,
discussion_entity  $discussion,
post_entity  $post,
bool  $hasreplies = false 
)

Can the user delete the post in this discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
post_entity$postThe post the user wants to delete
bool$hasrepliesWhether the post has replies
Return values
bool

◆ can_edit_post()

mod_forum\local\managers\capability::can_edit_post ( stdClass  $user,
discussion_entity  $discussion,
post_entity  $post 
)

Can the user edit the post in this discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
post_entity$postThe post the user wants to edit
Return values
bool

◆ can_export_discussions()

mod_forum\local\managers\capability::can_export_discussions ( stdClass  $user)

Can the user export (see portfolios) discussions in this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_export_forum()

mod_forum\local\managers\capability::can_export_forum ( stdClass  $user)

Checks whether the user can export the whole forum (discussions and posts).

Parameters
stdClass$userThe user object.
Return values
boolTrue if the user can export the forum or false otherwise.

◆ can_export_post()

mod_forum\local\managers\capability::can_export_post ( stdClass  $user,
post_entity  $post 
)

Can the user export (see portfolios) the post in this discussion?

Parameters
stdClass$userThe user to check
post_entity$postThe post the user wants to export
Return values
bool

◆ can_favourite_discussion()

mod_forum\local\managers\capability::can_favourite_discussion ( stdClass  $user)

Can the user favourite the discussion.

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_grade()

mod_forum\local\managers\capability::can_grade ( stdClass  $grader,
stdClass  $gradee = null 
)

Check whether the supplied grader can grade the gradee.

Parameters
stdClass$graderThe user grading
stdClass$gradeeThe user being graded
Return values
bool

◆ can_manage_forum()

mod_forum\local\managers\capability::can_manage_forum ( stdClass  $user)

Can the user manage this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_manage_tags()

mod_forum\local\managers\capability::can_manage_tags ( stdClass  $user)

Can the user manage tags on the site?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_manually_control_post_read_status()

mod_forum\local\managers\capability::can_manually_control_post_read_status ( stdClass  $user)

Can the user manually mark posts as read/unread in this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_move_discussion()

mod_forum\local\managers\capability::can_move_discussion ( stdClass  $user,
discussion_entity  $discussion 
)

Can the user move the discussion in this forum?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
Return values
bool

◆ can_move_discussions()

mod_forum\local\managers\capability::can_move_discussions ( stdClass  $user)

Can the user move discussions in this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_pin_discussion()

mod_forum\local\managers\capability::can_pin_discussion ( stdClass  $user,
discussion_entity  $discussion 
)

Is the user pin the discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
Return values
bool

◆ can_pin_discussions()

mod_forum\local\managers\capability::can_pin_discussions ( stdClass  $user)

Can the user pin discussions in this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_post_in_discussion()

mod_forum\local\managers\capability::can_post_in_discussion ( stdClass  $user,
discussion_entity  $discussion 
)

Can the user post in this discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
Return values
bool

◆ can_post_to_my_groups()

mod_forum\local\managers\capability::can_post_to_my_groups ( stdClass  $user)

Can the user post to their groups?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_reply_privately_to_post()

mod_forum\local\managers\capability::can_reply_privately_to_post ( stdClass  $user,
post_entity  $post 
)

Can the user reply privately to the specified post?

Parameters
stdClass$userThe user to check
post_entity$postThe post the user wants to reply to
Return values
bool

◆ can_reply_to_post()

mod_forum\local\managers\capability::can_reply_to_post ( stdClass  $user,
discussion_entity  $discussion,
post_entity  $post 
)

Can the user reply to the post in this discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
post_entity$postThe post the user wants to reply to
Return values
bool

◆ can_self_enrol()

mod_forum\local\managers\capability::can_self_enrol ( stdClass  $user)

Checks whether the user can self enrol into the course.

Mimics the checks on the add button in deprecatedlib/forum_print_latest_discussions

Parameters
stdClass$user
Return values
bool

◆ can_split_discussions()

mod_forum\local\managers\capability::can_split_discussions ( stdClass  $user)

Can the user split discussions in this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_split_post()

mod_forum\local\managers\capability::can_split_post ( stdClass  $user,
discussion_entity  $discussion,
post_entity  $post 
)

Can the user split the post in this discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
post_entity$postThe post the user wants to split
Return values
bool

◆ can_subscribe_to_discussion()

mod_forum\local\managers\capability::can_subscribe_to_discussion ( stdClass  $user,
discussion_entity  $discussion 
)

Can the user subscribe to the give discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
Return values
bool

◆ can_subscribe_to_forum()

mod_forum\local\managers\capability::can_subscribe_to_forum ( stdClass  $user)

Can the user subscribe to this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_view_any_private_reply()

mod_forum\local\managers\capability::can_view_any_private_reply ( stdClass  $user)

Whether the user can view any private reply in the forum.

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_view_discussion()

mod_forum\local\managers\capability::can_view_discussion ( stdClass  $user,
discussion_entity  $discussion 
)

Can the user view the content of a discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
Return values
bool

◆ can_view_discussions()

mod_forum\local\managers\capability::can_view_discussions ( stdClass  $user)

Can the user view discussions in this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_view_hidden_posts()

mod_forum\local\managers\capability::can_view_hidden_posts ( stdClass  $user)

Can the user view hidden posts in this forum?

Parameters
stdClass$userThe user to check
Return values
bool

◆ can_view_participants()

mod_forum\local\managers\capability::can_view_participants ( stdClass  $user,
discussion_entity  $discussion 
)

Can the user view the participants of this discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
Return values
bool

◆ can_view_post()

mod_forum\local\managers\capability::can_view_post ( stdClass  $user,
discussion_entity  $discussion,
post_entity  $post 
)

Can the user view the content of the post in this discussion?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
post_entity$postThe post the user wants to view
Return values
bool

◆ can_view_post_shell()

mod_forum\local\managers\capability::can_view_post_shell ( stdClass  $user,
post_entity  $post 
)

Can the user view the post at all? In some situations the user can view the shell of a post without being able to view its content.

Parameters
stdClass$userThe user to check
post_entity$postThe post the user wants to view
Return values
bool

◆ get_context()

mod_forum\local\managers\capability::get_context ( )
protected

Get the context for this capability manager.

Return values
context

◆ get_discussion_record()

mod_forum\local\managers\capability::get_discussion_record ( discussion_entity  $discussion)
protected

Get the legacy discussion record for the given discussion entity.

Parameters
discussion_entity$discussionThe discussion to convert
Return values
stdClass

◆ get_forum()

mod_forum\local\managers\capability::get_forum ( )
protected

Get the forum entity for this capability manager.

Return values
forum_entity

◆ get_forum_record()

mod_forum\local\managers\capability::get_forum_record ( )
protected

Get the legacy forum record for this forum.

Return values
stdClass

◆ get_post_record()

mod_forum\local\managers\capability::get_post_record ( post_entity  $post)
protected

Get the legacy post record for the given post entity.

Parameters
post_entity$postThe post to convert
Return values
stdClass

◆ must_post_before_viewing_discussion()

mod_forum\local\managers\capability::must_post_before_viewing_discussion ( stdClass  $user,
discussion_entity  $discussion 
)

Is the user required to post in the discussion before they can view it?

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
Return values
bool

◆ validate_delete_post()

mod_forum\local\managers\capability::validate_delete_post ( stdClass  $user,
discussion_entity  $discussion,
post_entity  $post,
bool  $hasreplies = false 
)

Verifies is the given user can delete a post.

Parameters
stdClass$userThe user to check
discussion_entity$discussionThe discussion to check
post_entity$postThe post the user wants to delete
bool$hasrepliesWhether the post has replies
Return values
bool
Exceptions
moodle_exception

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