Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Class for plans persistence.

Copyright: 2015 David Monllao
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 714 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: plan  - X-Ref

Class for loading/storing plans from the DB.

define_properties()   X-Ref
Return the definition of the properties of this model.

return: array

before_validate()   X-Ref
Hook to execute before validate.

return: void

can_comment()   X-Ref
Whether the current user can comment on this plan.

return: bool

can_manage()   X-Ref
Whether the current user can manage the plan.

return: bool

can_read()   X-Ref
Whether the current user can read the plan.

return: bool

can_read_comments()   X-Ref
Whether the current user can read comments on this plan.

return: bool

can_request_review()   X-Ref
Whether the current user can request a review of the plan.

return: bool

can_review()   X-Ref
Whether the current user can review the plan.

return: bool

get_comment_object()   X-Ref
Get the comment object.

return: comment

get_competencies()   X-Ref
Get the competencies in this plan.

return: competency[]

get_competency($competencyid)   X-Ref
Get a single competency from this plan.

This will throw an exception if the competency does not belong to the plan.

param: int $competencyid The competency ID.
return: competency

get_context()   X-Ref
Get the context in which the plan is attached.

return: context_user

get_statusname()   X-Ref
Human readable status name.

return: string

get_template()   X-Ref
Get the plan template.

return: template|null

is_draft()   X-Ref
Is the plan in draft mode?

This method is convenient to know if the plan is a draft because whilst a draft
is being reviewed its status is not "draft" any more, but it still is a draft nonetheless.

return: boolean

validate_templateid($value)   X-Ref
Validate the template ID.

param: mixed $value The value.
return: true|lang_string

validate_userid($value)   X-Ref
Validate the user ID.

param: int $value
return: true|lang_string

can_comment_user($planuserid)   X-Ref
Can the current user comment on a user's plan?

param: int $planuserid The user ID the plan belongs to.
return: bool

can_manage_user($planuserid)   X-Ref
Can the current user manage a user's plan?

param: int $planuserid The user to whom the plan would belong.
return: bool

can_manage_user_draft($planuserid)   X-Ref
Can the current user manage a user's draft plan?

param: int $planuserid The user to whom the plan would belong.
return: bool

can_read_comments_user($planuserid)   X-Ref
Can the current user read the comments on a user's plan?

param: int $planuserid The user ID the plan belongs to.
return: bool

can_read_user($planuserid)   X-Ref
Can the current user view a user's plan?

param: int $planuserid The user to whom the plan would belong.
return: bool

can_read_user_draft($planuserid)   X-Ref
Can the current user view a user's draft plan?

param: int $planuserid The user to whom the plan would belong.
return: bool

can_request_review_user($planuserid)   X-Ref
Can the current user request the draft to be reviewed.

param: int $planuserid The user to whom the plan would belong.
return: bool

can_review_user($planuserid)   X-Ref
Can the current user review the plan.

This means being able to send the plan from draft to active, and vice versa.

param: int $planuserid The user to whom the plan would belong.
return: bool

get_by_user_and_competency($userid, $competencyid)   X-Ref
Get the plans of a user containing a specific competency.

param: int $userid       The user ID.
param: int $competencyid The competency ID.
return: plans[]

get_draft_statuses()   X-Ref
Get the list of draft statuses.

return: array Contains the status constants.

get_recordset_for_due_and_incomplete()   X-Ref
Get the recordset of the plans that are due, incomplete and not draft.

return: \moodle_recordset

get_status_list($userid)   X-Ref
Return a list of status depending on capabilities.

param: int $userid The user to whom the plan would belong.
return: array

update_multiple_from_template(template $template)   X-Ref
Update from template.

Bulk update a lot of plans from a template

param: template $template
return: bool

is_based_on_template()   X-Ref
Check if a template is associated to the plan.

return: bool

can_be_edited()   X-Ref
Check if plan can be edited.

return: bool

validate_duedate($value)   X-Ref
Validate the due date.
When setting a due date it must not exceed the DUEDATE_THRESHOLD.

param: int $value The due date.
return: bool|lang_string

has_records_for_template($templateid)   X-Ref
Checks if a template has user plan records.

param: int $templateid The template ID
return: boolean

count_records_for_template($templateid, $status)   X-Ref
Count the number of plans for a template, optionally filtering by status.

param: int $templateid The template ID
param: int $status The plan status. 0 means all statuses.
return: int

get_records_for_template($templateid, $status = 0, $skip = 0, $limit = 100)   X-Ref
Get the plans for a template, optionally filtering by status.

param: int $templateid The template ID
param: int $status The plan status. 0 means all statuses.
param: int $skip The number of plans to skip
param: int $limit The max number of plans to return
return: int