if (count($c_q_list) > 0) { // Get the courses list if (strlen($dbNameForm) > 40) { error_log('Database name ' . $dbNameForm . ' is too long, skipping'); } elseif (!in_array($dbNameForm, $dblist)) { error_log('Database ' . $dbNameForm . ' was not found, skipping'); } else { iDatabase::select_db($dbNameForm); $res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code"); if ($res === false) { die('Error while querying the courses list in update_db-1.8.5-1.8.6.inc.php'); } if (iDatabase::num_rows($res) > 0) { $i = 0; $list = array(); while ($row = iDatabase::fetch_array($res)) { $list[] = $row; $i++; } foreach ($list as $row_course) { // Now use the $c_q_list /** * We connect to the right DB first to make sure we can use the queries * without a database name */ if (!$singleDbForm) { //otherwise just use the main one iDatabase::select_db($row_course['db_name']); }
$reflink_unique = array_unique($reflink); $reflink_flip = array_flip($reflink_unique); if (is_array($wiki_id)) { foreach ($wiki_id as $key => $wiki_page) { $pag_id = $reflink_flip[$reflink[$key]]; $sql= "UPDATE $t_wiki SET page_id='".($pag_id + 1)."' WHERE id = '$wiki_page'"; $res_update = iDatabase::query($sql); } } // Insert page_id into wiki_conf table, actually this table is empty $query = "SELECT DISTINCT page_id FROM $t_wiki ORDER BY page_id"; $myres_wiki = iDatabase::query($query); if (iDatabase::num_rows($myres_wiki) > 0) { while ($row_wiki = iDatabase::fetch_row($myres_wiki)) { $page_id = $row_wiki[0]; $query = "INSERT INTO ".$t_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3) VALUES ('".$page_id."','','','','','','','')"; $myres_wiki_conf = iDatabase::query($query); } } } } } } } else { echo 'You are not allowed here !' . __FILE__;
// Fill description type into course_description table $t_course_description = $row_course['db_name'].".course_description"; if ($singleDbForm) { $t_course_description = "$prefix{$row_course['db_name']}_course_description"; } // Get all ids and update description_type field with them from course_description table $sql_sel = "SELECT id FROM $t_course_description"; $rs_sel = iDatabase::query($sql_sel); if ($rs_sel === false) { Log::error('Could not query course_description ids table: '.iDatabase::error()); } else { if (iDatabase::num_rows($rs_sel) > 0) { while ($row_ids = iDatabase::fetch_array($rs_sel)) { $description_id = $row_ids['id']; $sql_upd = "UPDATE $t_course_description SET description_type='$description_id' WHERE id='$description_id'"; iDatabase::query($sql_upd); } } } } } } } } else {