This files describes API changes in HR Import,
information provided here is intended especially for developers.

=== 19.1.0 ===

* Added a new check that prevents HR Import from running when there are no records in a source and the source has the "Source contains all records" setting set to "Yes".
  * One failing source will log an error and be bypassed instead of preventing the entire import.
  * Added new check to the following methods:
    * elements/classes/hierarchy.element.class::check_sanity()
    * elements/jobassignment::check_sanity()
    * elements/user::check_sanity()
* Added a confirmation message when running HR Import that asks to confirm importing when a source has fewer records than the site does and the source has
  the "Source contains all records" settting set to "Yes". This is displayed in the admin/syncexecute.php entry file.
    * Modified the admin/syncexecute.php entry file to display the confirmation message when the 'confirm=1' param is specified
    * Added the following methods:
      * tool_totara_sync_get_confirmation_messages() in lib.php - returns the confirmation messages for each element to display before importing
      * get_confirmation_message() in elements/classes/element.class.php - returns the confirmation message to display before importing
      * get_current_import_count() in elements/classes/element.class.php - returns the number of records that will be imported
      * get_existing_import_count() in elements/classes/element.class.php - returns the number of existing imported records for the element in the site
      * get_current_to_existing_records_percentage() in elements/classes/element.class.php - returns the ratio of records that will be imported to existing records
* Added method get_table_name() in elements/classes/element.class.php which returns the name of the table that records are imported into
* Added method totara_sync_element::check_table_has_content() which returns a boolean based on whether there are records in the element table
* Added method tool_totara_sync_get_runnable_elements() in lib.php which returns the elements that are runnable
* Modified tool_totara_sync_run() in lib.php to use the new tool_totara_sync_get_runnable_elements() method
* Added method run_after_sync() in sources/classes/source.class.php which is called after the import has completed, which in the base class drops the temporary table
* Added run_after_sync() in source_comp_csv, source_user_csv, source_pos_csv, source_org_csv, source_jobassignment_csv which overrides the parent method
  to also cleanup the temporary files created by the CSV source as well as dropping the temporary table
* Added method tool_totara_sync\internal\source\csv_trait::cleanup_files() which removes the temporary files created by the CSV source

=== 19.0 ===

* totara_sync_source now includes the element name when throwing the missing temp table exceptions, previously incorrectly used 'get_element_name' as the exception

=== 17.0 ===

* New \source_user_csv::check_length_limit() method overrides \totara_sync_source::check_length_limit() in order to flag records as 'data_exceeded_length' where field length is exceeded,
    rather than deleting them from the dataset.
    * New totara_sync/elements/user::check_user_truncated_records() method to recognise the 'data_exceeded_length' flag on records.
    * Changed totara_sync/elements/user::check_sanity() to ignore truncated records.

=== 16.0 ===

* Removed deprecated functions:
  * \rb_source_totara_sync_log::rb_display_logtype()
  * \totara_sync_clean_fields()
  * \totara_sync_notify()
* Removed deprecated function arguments in:
  * \totara_sync_hierarchy::sync_item()
  * \totara_sync_element_user::create_user()
  * \totara_sync_element_user::put_custom_field_data()
  * \totara_sync_element_user::set_sync_user_fields()
* Removed deprecated strings:
  * nocsvfilepath,tool_totara_sync
  * notifymessagestart,tool_totara_sync
  * enablescheduledsync,tool_totara_sync
  * generalsettings,tool_totara_sync
  * managerjobassignmentidnumber,tool_totara_sync

=== 14.0 ===

=== 13.0 ===

  * The Job Assignment import field managerjobassignmentidnumber has been renamed to managerjaidnumber.
    NOTE: CVS or Database sources that do not have field mappings will require the source field name to be updated.

=== 12.0 ===

* Removed deprecated methods:
  * totara_sync_element_user::sync_user_assignments()
  * totara_sync_element_user::sync_user_job_assignments()
  * totara_sync_element_user::sync_user_dependant_job_assignment_fields()
  * totara_sync_element_user::get_invalid_org_pos()
  * totara_sync_element_user::get_invalid_start_end_dates()
  * totara_sync_element_user::get_invalid_roles()
  * totara_sync_element_user::check_self_assignment()
* The following functions now assume empty fields are processed in the source before being passed to the element:
  * sync_item() the third parameter is no longer used. Behaviour of the function has not changed.
  * create_user() the second parameter is no longer used. Behaviour of the function has not changed.
  * set_sync_user_fields the third parameter is no longer used. Behaviour of the function has not changed.
  * put_custom_field_data() the third parameter is no longer used. Behaviour of the function has not changed.
* rb_source_totara_sync_log::rb_display_logtype() has been deprecated, please call tool_totara_sync\rb\display\totara_sync_log_type::display instead().
* Syncing of elements now iterates through each element and runs the whole sync process, including checking for configuration
    errors, the import of data, triggering the event and notifying users, before going to the next element and repeating
    this process
* tool_totara_sync\event\sync_completed now contains a parameter within its 'other' data entry called 'element'. This contains
    the name of the element as returned by the get_name() method.
* When notifying users after completion of element syncing. The users will be notified only of log messages relating to that
  given run of that element, rather than all log messages since the last time users were notified.
* Tasks were added in the tool_totara_sync\task\ namespace which correspond to each element. These will run their individual elements.
* totara_core\task\tool_totara_sync_task is still in place, but this will run any elements that are set to run
    with the default scheduling.
* tool_totara_sync_run has had the first argument added to it, $isscheduledtask, which should be set to true so that only
    elements set to run on the default scheduled task are run.
* save_scheduled_task_from_form has had an optional second argument added to it, $task. This is to be set if you wish to save
    data against a task other than the default.
* totara_sync_notify has been deprecated. Elements should be run via totara_sync_element::run_sync(), which will notify users following the run.
    Alternatively, the protected method totara_sync_element::notify_user can perform this operation.
* The base source class now uses the element property in its constructor. In extended source classes, it is now recommended
    to assign a value to $this->element before calling parent::construct().

=== 11.0 ===

* Notifications and source field information has been moved out Element forms, affecting mark-up in the following methods:
  * csv_trait::config_form_add_csv_details()
  * totara_sync_source_org_csv::config_form()
  * totara_sync_source_pos_csv::config_form()
  * totara_sync_source_user_csv::config_form()
  * database_trait::totara_sync_source_org_database()
  * totara_sync_source_org_database::config_form()
  * totara_sync_source_pos_database::config_form()
  * totara_sync_source_user_database::config_form()


=== 10.0 ===

* totara_sync_element_user::get_invalid_emails() is now publicly accessible.
* totara_sync_element_user::get_invalid_lang() is now publicly accessible.
* Added new classes for importing job assignments:
   - totara_sync_element_jobassignment
   - totara_sync_source_jobassignment_csv
   - totara_sync_source_jobassignment_database
   Functionality relating to job assignments has been removed from the user element and sources.
* totara_sync_element_user::get_invalid_org_pos has been deprecated. Please use the new jobassignment element.
* totara_sync_element_user::get_invalid_start_end_dates has been deprecated. Please use the new jobassignment element.
* totara_sync_element_user::get_invalid_roles has been deprecated. Please use the new jobassignment element.
* totara_sync_element_user::check_self_assignment has been deprecated. Please use the new jobassignment element.
* totara_sync_element_user::sync_user_job_assignments has been deprecated. Please use the new jobassignment element.
* totara_sync_element_user::sync_user_dependant_job_assignment_fields has been deprecated. Please use the new jobassignment element.
* totara_sync_element_user::get_duplicated_values no longer take into account whether job assignments are enabled
