added a comment - - edited
I do not like this hack at all, it seems like it could work, but it creates new problems and backwards compatibility issues, sorry - the major issues is that it is using the "update" code path for adding of new activities.
The proper approach to solve this problem is IMO to modify the "add" path instead of the update path.
1/ add new parameter copyfrom and look for it when setting up default values for add activity form
2/ add new activity function which modifies the default data - it it is not there, just copy as much as possible from course_modules (groups, etc.) + activity name + description (with files), this shoudl be called before actually setting up the mform
3/ use the rest of standard activity insert code without any modifications at all
4/ the only necessary change in the form is the different button label
The proposed approach above only modifies the defaults in the add activity form instead of fragile hacking of activity update path.
I think these are big potential problems in the patch above:
1/ validation does not work, because it is usually designed to rely on the add/update flags and current cm id (doing update validation before insert is wrong) - BC issue that may lead to white pages or other breakage
2/ the form structure sometimes depends on existing data, which means update and insert forms may be different - again a big BC compatibility issue that might even lead to white pages or other breakage
I am just guessing, but all the idnumber duplicity checks would fail in the current patch, right?
Oleg, thanks for your suggestion. I'm just wondering how it's different from our current backup and restore functionality?