Permalink
Browse files

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

…nto MOODLE_24_STABLE
  • Loading branch information...
2 parents 00dba5b + 93b38fc commit ee8044f2e64f75a2983f4831773efe197aafd3ba @danpoltawski danpoltawski committed Jan 14, 2013
Showing with 11 additions and 14 deletions.
  1. +4 −12 backup/moodle2/restore_stepslib.php
  2. +7 −2 group/lib.php
@@ -824,20 +824,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
@@ -713,9 +713,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))) {
@@ -724,7 +725,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 ee8044f

Please sign in to comment.