dbprefix}curriculum WHERE cid={$curriculumid}"); foreach ($data as $d) { $is_sub = 0; if (in_array($d['id'], $subjects)) { $is_sub = 1; } $q = "INSERT INTO {$CONFIG->dbprefix}curriculum (eid, cid, start, end, level, isSubject, title, description) VALUES ("; $q .= $d['id'].', '; $q .= $curriculumid.', '; $q .= $d['start'].', '; $q .= $d['end'].', '; $q .= $d['level'].', '; $q .= $is_sub.', '; $q .= '"'.mysql_real_escape_string($d['title']['et']).'", '; if (isset($d['description'])) { $q .= '"'.mysql_real_escape_string($d['description']['et']). '") '; } else { $q .= '"")'; } insert_data($q); } } $taxonomymappers = $CONFIG->curriculum_config['taxonomymappers']; foreach ($CONFIG->curriculum_config['supported_curriculas'] as $curr) { if (in_array($curr, array_keys($taxonomymappers))) { $raw_contents = download($taxonomymappers[$curr][1].'all'); $contents = json_decode($raw_contents, true); $subjects = get_data("SELECT eid FROM {$CONFIG->dbprefix}curriculum WHERE isSubject AND cid={$taxonomymappers[$curr][0]}"); $sublist = array(); if ($subjects) { foreach($subjects as $s) { $sublist[] = $s->eid; } } _do_import($taxonomymappers[$curr][0], $sublist, $contents); unset($raw_contents); unset($contents); // maps $raw_maps = download($taxonomymappers[$curr][1].'maps'); $maps = json_decode($raw_maps, true); $taxes = $maps['taxonomies']; $goodtaxes = array(); $taxmap = array(); foreach($taxes as $tax => $taxns) { if (in_array($taxns, $CONFIG->curriculum_config['supported_curriculas'])) { $goodtaxes[] = $tax; $taxmap[$tax] = $taxonomymappers[$taxns][0]; } } foreach($maps['list'] as $one) { $taxfrom = $one['from']['tax']; $taxto = $one['to']['tax']; if (!in_array($taxfrom, $goodtaxes) || !in_array($taxto, $goodtaxes)) continue; $q = "INSERT INTO elggcurriculum_map (fromtax, totax, fromeid, toeid) VALUES ("; $q .= $taxmap[$taxfrom].","; $q .= $taxmap[$taxto].","; $q .= $one['from']['id'].","; $q .= $one['to']['id'].")"; insert_data($q); } unset($raw_maps); unset($maps); } } ?>