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.
/mod/folder/ -> lib.php (source)

Functions that are not part of a class:

folder_supports($feature)   X-Ref
List of features supported in Folder module

param: string $feature FEATURE_xx constant for requested feature
return: mixed True if module supports feature, false if not, null if doesn't know

folder_reset_userdata($data)   X-Ref
This function is used by the reset_course_userdata function in moodlelib.

param: $data the data submitted from the reset course.
return: array status array

folder_get_view_actions()   X-Ref
List the actions that correspond to a view of this module.
This is used by the participation report.

Note: This is not used by new logging system. Event with
crud = 'r' and edulevel = LEVEL_PARTICIPATING will
be considered as view action.

return: array

folder_get_post_actions()   X-Ref
List the actions that correspond to a post of this module.
This is used by the participation report.

Note: This is not used by new logging system. Event with
crud = ('c' || 'u' || 'd') and edulevel = LEVEL_PARTICIPATING
will be considered as post action.

return: array

folder_add_instance($data, $mform)   X-Ref
Add folder instance.

param: object $data
param: object $mform
return: int new folder instance id

folder_update_instance($data, $mform)   X-Ref
Update folder instance.

param: object $data
param: object $mform
return: bool true

folder_delete_instance($id)   X-Ref
Delete folder instance.

param: int $id
return: bool true

folder_get_file_areas($course, $cm, $context)   X-Ref
Lists all browsable file areas

param: stdClass $course course object
param: stdClass $cm course module object
param: stdClass $context context object
return: array

folder_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)   X-Ref
File browsing support for folder module content area.

param: file_browser $browser file browser instance
param: array $areas file areas
param: stdClass $course course object
param: stdClass $cm course module object
param: stdClass $context context object
param: string $filearea file area
param: int $itemid item ID
param: string $filepath file path
param: string $filename file name
return: file_info instance or null if not found

folder_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()   X-Ref
Serves the folder files.

param: stdClass $course course object
param: stdClass $cm course module
param: stdClass $context context object
param: string $filearea file area
param: array $args extra arguments
param: bool $forcedownload whether or not force download
param: array $options additional options affecting the file serving
return: bool false if file not found, does not return if found - just send the file

folder_page_type_list($pagetype, $parentcontext, $currentcontext)   X-Ref
Return a list of page types

param: string $pagetype current page type
param: stdClass $parentcontext Block's parent context
param: stdClass $currentcontext Current context of block

folder_export_contents($cm, $baseurl)   X-Ref
Export folder resource contents

return: array of file content

folder_dndupload_register()   X-Ref
Register the ability to handle drag and drop file uploads

return: array containing details of the files / types the mod can handle

folder_dndupload_handle($uploadinfo)   X-Ref
Handle a file that has been uploaded

param: object $uploadinfo details of the file / content that has been uploaded
return: int instance id of the newly created mod

folder_get_coursemodule_info($cm)   X-Ref
Given a coursemodule object, this function returns the extra
information needed to print this activity in various places.

If folder needs to be displayed inline we store additional information
in customdata, so functions {@link folder_cm_info_dynamic()} and
{@link folder_cm_info_view()} do not need to do DB queries

param: cm_info $cm
return: cached_cm_info info

folder_cm_info_dynamic(cm_info $cm)   X-Ref
Sets dynamic information about a course module

This function is called from cm_info when displaying the module
mod_folder can be displayed inline on course page and therefore have no course link

param: cm_info $cm

folder_cm_info_view(cm_info $cm)   X-Ref
Overwrites the content in the course-module object with the folder files list
if folder.display == FOLDER_DISPLAY_INLINE

param: cm_info $cm

folder_view($folder, $course, $cm, $context)   X-Ref
Mark the activity completed (if required) and trigger the course_module_viewed event.

param: stdClass $folder     folder object
param: stdClass $course     course object
param: stdClass $cm         course module object
param: stdClass $context    context object

folder_archive_available($folder, $cm)   X-Ref
Check if the folder can be zipped and downloaded.

param: stdClass $folder
param: context_module $cm
return: bool True if the folder can be zipped and downloaded.

folder_get_directory_size($directory)   X-Ref
Recursively measure the size of the files in a directory.

param: array $directory
return: int size of directory contents in bytes

folder_downloaded($folder, $course, $cm, $context)   X-Ref
Mark the activity completed (if required) and trigger the all_files_downloaded event.

param: stdClass $folder     folder object
param: stdClass $course     course object
param: stdClass $cm         course module object
param: stdClass $context    context object

folder_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0)   X-Ref
Returns all uploads since a given time in specified folder.

param: array $activities
param: int $index
param: int $timestart
param: int $courseid
param: int $cmid
param: int $userid
param: int $groupid not used, but required for compatibilty with other modules

folder_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames)   X-Ref
Outputs the folder uploads indicated by $activity.

param: object $activity      the activity object the folder resides in
param: int    $courseid      the id of the course the folder resides in
param: bool   $detail        not used, but required for compatibilty with other modules
param: int    $modnames      not used, but required for compatibilty with other modules
param: bool   $viewfullnames not used, but required for compatibilty with other modules

folder_get_recent_activity($context, $timestart, $userid=0)   X-Ref
Gets recent file uploads in a given folder. Does not perform security checks.

param: object $context
param: int $timestart
param: int $userid
return: array

folder_print_recent_activity($course, $viewfullnames, $timestart)   X-Ref
Given a course and a date, prints a summary of all the new
files posted in folder resources since that date

param: object $course
param: bool $viewfullnames capability
param: int $timestart
return: bool success

folder_check_updates_since(cm_info $cm, $from, $filter = array()   X-Ref
Check if the module has any update that affects the current user since a given time.

param: cm_info $cm course module data
param: int $from the time to check updates from
param: array $filter  if we need to check only specific updates
return: stdClass an object with the different type of areas indicating if they were updated or not

mod_folder_core_calendar_provide_event_action(calendar_event $event,\core_calendar\action_factory $factory,int $userid = 0)   X-Ref
This function receives a calendar event and returns the action associated with it, or null if there is none.

This is used by block_myoverview in order to display the event appropriately. If null is returned then the event
is not displayed on the block.

param: calendar_event $event
param: \core_calendar\action_factory $factory
param: int $userid User id to use for all capability checks, etc. Set to 0 for current user (default).
return: \core_calendar\local\event\entities\action_interface|null

mod_folder_get_path_from_pluginfile(string $filearea, array $args)   X-Ref
Given an array with a file path, it returns the itemid and the filepath for the defined filearea.

param: string $filearea The filearea.
param: array  $args The path (the part after the filearea and before the filename).
return: array The itemid and the filepath inside the $args path, for the defined filearea.