MDL-30797 - backup groups: Added a parameter to the groups_assign_grouping function.

$timeadded has now been included so that the backup / restore functions can now use
this API rather than duplicating the code.