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__;

}
예제 #2
0
function parse_sql_queries($sql_text)
{
    //split in array of sql strings
    $sql_instructions = array();
    split_sql_file($sql_instructions, $sql_text);
    //execute the sql instructions
    $count = count($sql_instructions);
    for ($i = 0; $i < $count; $i++) {
        $this_sql_query = $sql_instructions[$i]['query'];
        //UTF8 fix see #5678
        if (strpos(strtolower($this_sql_query), 'create table') === false) {
            iDatabase::query($this_sql_query);
        } else {
            //$this_sql_query .= substr($this_sql_query, strlen($this_sql_query), strlen($this_sql_query)-1);
            $this_sql_query .= ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ';
            iDatabase::query($this_sql_query);
        }
    }
}
                            $res = iDatabase::query($query);
                            if ($log) {
                                Log::notice("In " . $row_course['db_name'] . ", executed: $query");
                            }
                        }
                    }

                    $t_d = $row_course['db_name'] . ".document";
                    $t_ip = $row_course['db_name'] . ".item_property";

                    if ($singleDbForm) {
                        $t_d = "$prefix{$row_course['db_name']}_document";
                        $t_ip = "$prefix{$row_course['db_name']}_item_property";
                    }
                    // Shared documents folder
                    $query = "INSERT INTO $t_d (path,title,filetype,size) VALUES ('/shared_folder','" . get_lang('SharedDocumentsDirectory') . "','folder','0')";
                    $myres = iDatabase::query($query);
                    if ($myres !== false) {
                        $doc_id = iDatabase::insert_id();
                        $query = "INSERT INTO $t_ip (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$doc_id,'FolderAdded',1,0,NULL,1)";
                        $myres = iDatabase::query($query);
                    }
                }
            }
        }
    }
} else {

    echo 'You are not allowed here !' . __FILE__;
}
            $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '1', 'AtOnce',1) ";
            $result = iDatabase::query($sql);
            $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '8', 'Daily',2) ";
            $result = iDatabase::query($sql);
            $sql = "INSERT INTO $dbNameForm.user_field_options (field_id, option_value, option_display_text, option_order) values ($id, '0', 'No',3) ";
            $result = iDatabase::query($sql);
                     
            //Fixing table access_url_rel_course if the platform have courses that were created in Dok€os 1.8.5
              
            if (!isset($_configuration['multiple_access_urls']) || $_configuration['multiple_access_urls'] == false) {
                $sql = "SELECT code FROM $dbNameForm.course";
                $result = iDatabase::query($sql);
                while ($row = iDatabase::fetch_array($result)) {
                    //Adding course to default URL just in case
                    $sql = "INSERT INTO $dbNameForm.access_url_rel_course SET course_code = '".iDatabase::escape_string($row['code'])."', access_url_id = '1' ";  
                    iDatabase::query($sql);
                }                
            }
        }
    }
    
    




    /* // This fragment of code is not necessary so far.
    // Get the courses databases queries list (c_q_list)
    $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql', 'course');
    if (count($c_q_list) > 0) {
        // Get the courses list
function check_work($folder_id, $work_url, $work_table, $base_work_dir) {
    $uniq_id = uniqid();
    //Looking for subfolders
    $sql 	= "SELECT * FROM $work_table WHERE parent_id = $folder_id AND filetype ='folder'";             
    $result = Database::query($sql);

    if (Database::num_rows($result)) {
        while ($row = Database::fetch_array($result, 'ASSOC')) {
            check_work($row['id'], $row['url'], $work_table, $base_work_dir);
        }
    }

    //Moving the subfolder in the root
    $new_url = '/'.basename($work_url).'_mv_'.$uniq_id;              
    $new_url = Database::escape_string($new_url);
    $sql = "UPDATE $work_table SET url = '$new_url', parent_id = 0 WHERE id = $folder_id";
    iDatabase::query($sql);

    if (is_dir($base_work_dir.$work_url)) {
        rename($base_work_dir.$work_url, $base_work_dir.$new_url);

        //Rename all files inside the folder                        
        $sql 	= "SELECT * FROM $work_table WHERE parent_id = $folder_id AND filetype ='file'";             
        $result = Database::query($sql);

        if (Database::num_rows($result)) {
            while ($row = Database::fetch_array($result, 'ASSOC')) {                                
                $new_url = "work".$new_url.'/'.basename($row['url']);     
                $new_url = Database::escape_string($new_url);
                $sql = "UPDATE $work_table SET url = '$new_url', parent_id = $folder_id, contains_file = '1' WHERE id = {$row['id']}";                                
                iDatabase::query($sql);
            }
        }
    }
}
    }
    fwrite($fh, '?>');
    fclose($fh);

    $sys_course_path = $pathForm . 'courses/';

    //$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
    //// Linking (The following line is disabled, connection has been already done)
    //$res = @iDatabase::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
    //iDatabase::select_db($dbNameForm, $link);
    iDatabase::select_db($dbNameForm);

    $db_name = $dbNameForm;
    $sql = "SELECT * FROM $db_name.course";
    Log::notice('Getting courses for files updates: ' . $sql);
    $result = iDatabase::query($sql);

    while ($courses_directories = iDatabase::fetch_array($result)) {

        $currentCourseRepositorySys = $sys_course_path . $courses_directories['directory'] . '/';

        $db_name = $courses_directories['db_name'];
        $origCRS = $updatePath . 'courses/' . $courses_directories['directory'];

        if (!is_dir($origCRS)) {
            Log::error('Directory ' . $origCRS . ' does not exist. Skipping.');
            continue;
        }
        // Move everything to the new hierarchy (from old path to new path)
        Log::notice('Renaming ' . $origCRS . ' to ' . $sys_course_path . $courses_directories['directory']);
        rename($origCRS, $sys_course_path . $courses_directories['directory']);
                    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 {

	echo 'You are not allowed here !' . __FILE__;

}