Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 93b38fc5a693b2ae6abc257d7fad016c67b5107b 1 parent b03d925
Adrian Greeve authored January 08, 2013
5  backup/moodle2/restore_stepslib.php
@@ -825,8 +825,11 @@ public function process_grouping($data) {
825 825
 
826 826
     public function process_grouping_group($data) {
827 827
         global $CFG;
  828
+
828 829
         require_once($CFG->dirroot.'/group/lib.php');
829  
-        groups_assign_grouping($this->get_new_parentid('grouping'), $this->get_mappingid('group', $data->groupid));
  830
+
  831
+        $data = (object)$data;
  832
+        groups_assign_grouping($this->get_new_parentid('grouping'), $this->get_mappingid('group', $data->groupid), $data->timeadded);
830 833
     }
831 834
 
832 835
     protected function after_execute() {
9  group/lib.php
@@ -713,9 +713,10 @@ function groups_parse_name($format, $groupnumber) {
713 713
  *
714 714
  * @param int groupingid
715 715
  * @param int groupid
  716
+ * @param int $timeadded  The time the group was added to the grouping.
716 717
  * @return bool true or exception
717 718
  */
718  
-function groups_assign_grouping($groupingid, $groupid) {
  719
+function groups_assign_grouping($groupingid, $groupid, $timeadded = null) {
719 720
     global $DB;
720 721
 
721 722
     if ($DB->record_exists('groupings_groups', array('groupingid'=>$groupingid, 'groupid'=>$groupid))) {
@@ -724,7 +725,11 @@ function groups_assign_grouping($groupingid, $groupid) {
724 725
     $assign = new stdClass();
725 726
     $assign->groupingid = $groupingid;
726 727
     $assign->groupid    = $groupid;
727  
-    $assign->timeadded  = time();
  728
+    if ($timeadded != null) {
  729
+        $assign->timeadded = (integer)$timeadded;
  730
+    } else {
  731
+        $assign->timeadded = time();
  732
+    }
728 733
     $DB->insert_record('groupings_groups', $assign);
729 734
 
730 735
     return true;

0 notes on commit 93b38fc

Please sign in to comment.
Something went wrong with that request. Please try again.