Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'wip-MDL-30797-23' of git://github.com/abgreeve/moodle i…

…nto MOODLE_23_STABLE
  • Loading branch information...
commit a07dccc1c5cf35d4ce3aaba35ff7f471f31d64b7 2 parents 4012fc4 + e25a7aa
@danpoltawski danpoltawski authored
Showing with 11 additions and 14 deletions.
  1. +4 −12 backup/moodle2/restore_stepslib.php
  2. +7 −2 group/lib.php
View
16 backup/moodle2/restore_stepslib.php
@@ -843,20 +843,12 @@ public function process_grouping($data) {
}
public function process_grouping_group($data) {
- global $DB;
-
- $data = (object)$data;
-
- $data->groupingid = $this->get_new_parentid('grouping'); // Use new parentid
- $data->groupid = $this->get_mappingid('group', $data->groupid); // Get from mappings
+ global $CFG;
- $params = array();
- $params['groupingid'] = $data->groupingid;
- $params['groupid'] = $data->groupid;
+ require_once($CFG->dirroot.'/group/lib.php');
- if (!$DB->record_exists('groupings_groups', $params)) {
- $DB->insert_record('groupings_groups', $data); // No need to set this mapping (no child info nor files)
- }
+ $data = (object)$data;
+ groups_assign_grouping($this->get_new_parentid('grouping'), $this->get_mappingid('group', $data->groupid), $data->timeadded);
}
protected function after_execute() {
View
9 group/lib.php
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.