Permalink
Browse files

MDL-30797 - backup groups: Added a parameter to the groups_assign_gro…

…uping function.

$timeadded has now been included so that the backup / restore functions can now use
this API rather than duplicating the code.
  • Loading branch information...
1 parent a2bbc96 commit e25a7aa27ee13217df3210deb11b4ce758dd2099 @abgreeve abgreeve committed Jan 8, 2013
Showing with 11 additions and 3 deletions.
  1. +4 −1 backup/moodle2/restore_stepslib.php
  2. +7 −2 group/lib.php
@@ -844,8 +844,11 @@ public function process_grouping($data) {
public function process_grouping_group($data) {
global $CFG;
+
require_once($CFG->dirroot.'/group/lib.php');
- groups_assign_grouping($this->get_new_parentid('grouping'), $this->get_mappingid('group', $data->groupid));
+
+ $data = (object)$data;
+ groups_assign_grouping($this->get_new_parentid('grouping'), $this->get_mappingid('group', $data->groupid), $data->timeadded);
}
protected function after_execute() {
View
@@ -634,9 +634,10 @@ function groups_parse_name($format, $groupnumber) {
*
* @param int groupingid
* @param int groupid
+ * @param int $timeadded The time the group was added to the grouping.
* @return bool true or exception
*/
-function groups_assign_grouping($groupingid, $groupid) {
+function groups_assign_grouping($groupingid, $groupid, $timeadded = null) {
global $DB;
if ($DB->record_exists('groupings_groups', array('groupingid'=>$groupingid, 'groupid'=>$groupid))) {
@@ -645,7 +646,11 @@ function groups_assign_grouping($groupingid, $groupid) {
$assign = new stdClass();
$assign->groupingid = $groupingid;
$assign->groupid = $groupid;
- $assign->timeadded = time();
+ if ($timeadded != null) {
+ $assign->timeadded = (integer)$timeadded;
+ } else {
+ $assign->timeadded = time();
+ }
$DB->insert_record('groupings_groups', $assign);
return true;

0 comments on commit e25a7aa

Please sign in to comment.