Merge branch 'wip-MDL-30797-23' of git://github.com/abgreeve/moodle into MOODLE_23_STABLE
This commit is contained in:
@@ -843,20 +843,12 @@ class restore_groups_structure_step extends restore_structure_step {
|
||||
}
|
||||
|
||||
public function process_grouping_group($data) {
|
||||
global $DB;
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->dirroot.'/group/lib.php');
|
||||
|
||||
$data = (object)$data;
|
||||
|
||||
$data->groupingid = $this->get_new_parentid('grouping'); // Use new parentid
|
||||
$data->groupid = $this->get_mappingid('group', $data->groupid); // Get from mappings
|
||||
|
||||
$params = array();
|
||||
$params['groupingid'] = $data->groupingid;
|
||||
$params['groupid'] = $data->groupid;
|
||||
|
||||
if (!$DB->record_exists('groupings_groups', $params)) {
|
||||
$DB->insert_record('groupings_groups', $data); // No need to set this mapping (no child info nor files)
|
||||
}
|
||||
groups_assign_grouping($this->get_new_parentid('grouping'), $this->get_mappingid('group', $data->groupid), $data->timeadded);
|
||||
}
|
||||
|
||||
protected function after_execute() {
|
||||
|
||||
+7
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user