Class containing a set of helpers.  
 More...
|  | 
| static | generate_shortname ($data, $templateshortname) | 
|  | Generate a shortname based on a template. 
 | 
|  | 
| static | generate_shortname_callback ($fullname, $idnumber, $block) | 
|  | Callback used when generating a shortname based on a template. 
 | 
|  | 
| static | get_course_formats () | 
|  | Return the available course formats. 
 | 
|  | 
| static | get_coursesection_count ($shortname) | 
|  | Helper to detect how many sections a course with a given shortname has. 
 | 
|  | 
| static | get_custom_course_field_data (array $data, array $defaults, context $context, array &$errors=[]) | 
|  | Return any elements from passed $data whose key matches one of the custom course fields defined for the site. 
 | 
|  | 
| static | get_custom_course_field_names () | 
|  | Return array of custom field element names. 
 | 
|  | 
| static | get_custom_course_fields () | 
|  | Return array of all custom course fields indexed by their shortname. 
 | 
|  | 
| static | get_enrolment_data ($data) | 
|  | Extract enrolment data from passed data. 
 | 
|  | 
| static | get_enrolment_plugins () | 
|  | Return the enrolment plugins. 
 | 
|  | 
| static | get_restore_content_dir ($backupfile=null, $shortname=null, &$errors=array()) | 
|  | Get the restore content tempdir. 
 | 
|  | 
| static | get_role_ids () | 
|  | Return the role IDs. 
 | 
|  | 
| static | get_role_names ($data, &$errors=array()) | 
|  | Get the role renaming data from the passed data. 
 | 
|  | 
| static | increment_idnumber ($idnumber) | 
|  | Helper to increment an ID number. 
 | 
|  | 
| static | increment_shortname ($shortname) | 
|  | Helper to increment a shortname. 
 | 
|  | 
| static | resolve_category ($data, &$errors=array()) | 
|  | Resolve a category based on the data passed. 
 | 
|  | 
| static | resolve_category_by_idnumber ($idnumber) | 
|  | Resolve a category by ID number. 
 | 
|  | 
| static | resolve_category_by_path (array $path) | 
|  | Resolve a category by path. 
 | 
|  | 
Class containing a set of helpers. 
- Copyright
- 2013 Frédéric Massart 
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 
◆ generate_shortname()
  
  | 
        
          | static tool_uploadcourse_helper::generate_shortname | ( |  | $data, |  
          |  |  |  | $templateshortname ) |  | static | 
 
Generate a shortname based on a template. 
- Parameters
- 
  
    | array | object | $data | course data. |  | string | $templateshortname | template of shortname. |  
 
- Return values
- 
  
    | null|string | shortname based on the template, or null when an error occured. |  
 
 
 
◆ generate_shortname_callback()
  
  | 
        
          | static tool_uploadcourse_helper::generate_shortname_callback | ( |  | $fullname, |  
          |  |  |  | $idnumber, |  
          |  |  |  | $block ) |  | static | 
 
Callback used when generating a shortname based on a template. 
- Parameters
- 
  
    | string | $fullname | full name. |  | string | $idnumber | ID number. |  | array | $block | result from preg_replace_callback. |  
 
- Return values
- 
  
  
 
 
◆ get_course_formats()
  
  | 
        
          | static tool_uploadcourse_helper::get_course_formats | ( |  | ) |  |  | static | 
 
Return the available course formats. 
- Return values
- 
  
  
 
 
◆ get_coursesection_count()
  
  | 
        
          | static tool_uploadcourse_helper::get_coursesection_count | ( |  | $shortname | ) |  |  | static | 
 
Helper to detect how many sections a course with a given shortname has. 
- Parameters
- 
  
    | string | $shortname | shortname of a course to count sections from. |  
 
- Return values
- 
  
    | integer | count of sections. |  
 
 
 
◆ get_custom_course_field_data()
  
  | 
        
          | static tool_uploadcourse_helper::get_custom_course_field_data | ( | array | $data, |  
          |  |  | array | $defaults, |  
          |  |  | context | $context, |  
          |  |  | array & | $errors = [] ) |  | static | 
 
Return any elements from passed $data whose key matches one of the custom course fields defined for the site. 
- Parameters
- 
  
    | array | $data |  |  | array | $defaults |  |  | context | $context |  |  | array | $errors | Will be populated with any errors |  
 
- Return values
- 
  
  
 
 
◆ get_custom_course_field_names()
  
  | 
        
          | static tool_uploadcourse_helper::get_custom_course_field_names | ( |  | ) |  |  | static | 
 
Return array of custom field element names. 
- Return values
- 
  
  
 
 
◆ get_custom_course_fields()
  
  | 
        
          | static tool_uploadcourse_helper::get_custom_course_fields | ( |  | ) |  |  | static | 
 
Return array of all custom course fields indexed by their shortname. 
- Return values
- 
  
    | core_customfield\field_controller[] |  |  
 
 
 
◆ get_enrolment_data()
  
  | 
        
          | static tool_uploadcourse_helper::get_enrolment_data | ( |  | $data | ) |  |  | static | 
 
Extract enrolment data from passed data. 
Constructs an array of methods, and their options: array( 'method1' => array( 'option1' => value, 'option2' => value ), 'method2' => array( 'option1' => value, 'option2' => value ) )
- Parameters
- 
  
    | array | $data | data to extract the enrolment data from. |  
 
- Return values
- 
  
  
 
 
◆ get_enrolment_plugins()
  
  | 
        
          | static tool_uploadcourse_helper::get_enrolment_plugins | ( |  | ) |  |  | static | 
 
Return the enrolment plugins. 
The result is cached for faster execution.
- Return values
- 
  
  
 
 
◆ get_restore_content_dir()
  
  | 
        
          | static tool_uploadcourse_helper::get_restore_content_dir | ( |  | $backupfile = null, |  
          |  |  |  | $shortname = null, |  
          |  |  | & | $errors = array() ) |  | static | 
 
Get the restore content tempdir. 
The tempdir is the sub directory in which the backup has been extracted.
This caches the result for better performance, but $CFG->keeptempdirectoriesonbackup needs to be enabled, otherwise the cache is ignored.
- Parameters
- 
  
    | string | $backupfile | path to a backup file. |  | string | $shortname | shortname of a course. |  | array | $errors | will be populated with errors found. |  
 
- Return values
- 
  
    | string|false | false when the backup couldn't retrieved. |  
 
 
 
◆ get_role_ids()
  
  | 
        
          | static tool_uploadcourse_helper::get_role_ids | ( |  | ) |  |  | static | 
 
Return the role IDs. 
The result is cached for faster execution.
- Return values
- 
  
  
 
 
◆ get_role_names()
  
  | 
        
          | static tool_uploadcourse_helper::get_role_names | ( |  | $data, |  
          |  |  | & | $errors = array() ) |  | static | 
 
Get the role renaming data from the passed data. 
- Parameters
- 
  
    | array | $data | data to extract the names from. |  | array | $errors | will be populated with errors found. |  
 
- Return values
- 
  
    | array | where the key is the role_<id>, the value is the new name. |  
 
 
 
◆ increment_idnumber()
  
  | 
        
          | static tool_uploadcourse_helper::increment_idnumber | ( |  | $idnumber | ) |  |  | static | 
 
Helper to increment an ID number. 
This first checks if the ID number is in use.
- Parameters
- 
  
    | string | $idnumber | ID number to increment. |  
 
- Return values
- 
  
  
 
 
◆ increment_shortname()
  
  | 
        
          | static tool_uploadcourse_helper::increment_shortname | ( |  | $shortname | ) |  |  | static | 
 
Helper to increment a shortname. 
This considers that the shortname passed has to be incremented.
- Parameters
- 
  
    | string | $shortname | shortname to increment. |  
 
- Return values
- 
  
  
 
 
◆ resolve_category()
  
  | 
        
          | static tool_uploadcourse_helper::resolve_category | ( |  | $data, |  
          |  |  | & | $errors = array() ) |  | static | 
 
Resolve a category based on the data passed. 
Key accepted are:
- category, which is supposed to be a category ID.
- category_idnumber
- category_path, array of categories from parent to child.
- Parameters
- 
  
    | array | $data | to resolve the category from. |  | array | $errors | will be populated with errors found. |  
 
- Return values
- 
  
  
 
 
◆ resolve_category_by_idnumber()
  
  | 
        
          | static tool_uploadcourse_helper::resolve_category_by_idnumber | ( |  | $idnumber | ) |  |  | static | 
 
Resolve a category by ID number. 
- Parameters
- 
  
    | string | $idnumber | category ID number. |  
 
- Return values
- 
  
  
 
 
◆ resolve_category_by_path()
  
  | 
        
          | static tool_uploadcourse_helper::resolve_category_by_path | ( | array | $path | ) |  |  | static | 
 
Resolve a category by path. 
- Parameters
- 
  
    | array | $path | category names indexed from parent to children. |  
 
- Return values
- 
  
  
 
 
The documentation for this class was generated from the following file: