瀏覽代碼

[svn r10884] Removed deprecated functions.
Removed deprecated course-migration code.
Added MAX_COURSES limit

Yannick Warnier 18 年之前
父節點
當前提交
1544ee71e9
共有 1 個文件被更改,包括 3 次插入344 次删除
  1. 3 344
      main/install/update-db-1.6.x-1.8.0.inc.php

+ 3 - 344
main/install/update-db-1.6.x-1.8.0.inc.php

@@ -245,9 +245,11 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		if($res===false){die('Error while querying the courses list in update_db.inc.php');}
 		if(mysql_num_rows($res)>0)
 		{
-			while($row = mysql_fetch_array($res))
+			$i=0;
+			while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
 			{
 				$list[] = $row;
+				$i++;
 			}
 			foreach($list as $row)
 			{
@@ -336,352 +338,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			}
 		}
 	}
-
-	$newPath = str_replace('\\', '/', realpath('../..')).'/';
-
-	$coursePath = array ();
-	$courseDB = array ();
-	$nbr_courses = 0;
-
-	if ($result = mysql_query("SELECT code,db_name,directory,course_language FROM `$dbNameForm`.`course` WHERE target_course_code IS NULL"))
-	{
-		$i = 0;
-
-		$nbr_courses = mysql_num_rows($result);
-
-		while ($i < MAX_COURSE_TRANSFER && (list ($course_code, $mysql_base_course, $directory, $languageCourse) = mysql_fetch_row($result)))
-		{
-			if (!file_exists($newPath.'courses/'.$directory))
-			{
-				if ($singleDbForm)
-				{
-					$prefix = $_configuration['table_prefix'].$mysql_base_course.$_configuration['db_glue'];
-
-					$mysql_base_course = $dbNameForm.'`.`'.$_configuration['table_prefix'].$mysql_base_course;
-				}
-				else
-				{
-					$prefix = '';
-				}
-
-				$coursePath[$course_code] = $directory;
-				$courseDB[$course_code] = $mysql_base_course;
-
-				include ("../lang/english/create_course.inc.php");
-
-				if ($languageCourse != 'english')
-				{
-					include ("../lang/$languageCourse/create_course.inc.php");
-				}
-
-				//TODO process the whole course database migration here. Call an external
-				//script/function to keep this script tidy
-
-				// Set item-properties of dropbox files
-				/*
-				$sql = "SELECT * FROM `$mysql_base_course".$_configuration['db_glue']."dropbox_file` f, `".$_configuration['db_glue']."_base_course".$_configuration['db_glue']."dropbox_post` p WHERE f.id = p.file_id";
-				$res = mysql_query($sql);
-				while ($obj = mysql_fetch_object($res))
-				{
-					$sql = "INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property` SET ";
-					$sql .= " tool = '".TOOL_DROPBOX."', ";
-					$sql .= " insert_date = '".$obj->upload_date."', ";
-					$sql .= " lastedit_date = '".$obj->last_upload_date."', ";
-					$sql .= " ref = '".$obj->id."', ";
-					$sql .= " lastedit_type = 'DropboxFileAdded', ";
-					$sql .= " to_group_id = '0', ";
-					$sql .= " to_user_id = '".$obj->dest_user_id."', ";
-					$sql .= " insert_user_id = '".$obj->uploader_id."'";
-					mysql_query($sql);
-				}
-				*/
-
-				$i ++;
-			}
-			else
-			{
-				$nbr_courses --;
-			}
-		}
-	}
 }
 else
 {
 	echo 'You are not allowed here !';
 }
-
-
-
-
-
-
-
-
-/**
-* This function stores the forum category in the database. The new category is added to the end. 
-* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
-*/
-function store_forumcategory($values)
-{
-	global $table_categories; 
-	global $_course;
-	global $_user; 
-	
-	// find the max cat_order. The new forum category is added at the end => max cat_order + &
-	$sql="SELECT MAX(cat_order) as sort_max FROM ".mysql_real_escape_string($table_categories);
-	$result=api_sql_query($sql);
-	$row=mysql_fetch_array($result);
-	$new_max=$row['sort_max']+1;
-
-	$sql="INSERT INTO ".$table_categories." (cat_title, cat_comment, cat_order) VALUES ('".mysql_real_escape_string($values['forum_category_title'])."','".mysql_real_escape_string($values['forum_category_comment'])."','".mysql_real_escape_string($new_max)."')";
-	api_sql_query($sql); 
-	$last_id=mysql_insert_id();
-	api_item_property_update($_course, TOOL_FORUM_CATEGORY, $last_id,"ForumCategoryAdded", $_user['user_id']);
-	return array('id'=>$last_id,'title'=>$values['forum_category_title']) ;
-}
-
-/**
-* This function stores the forum in the database. The new forum is added to the end. 
-* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
-*/
-function store_forum($values)
-{
-	global $table_forums; 
-	global $_course;
-	global $_user; 
-
-	// find the max forum_order for the given category. The new forum is added at the end => max cat_order + &
-	$sql="SELECT MAX(forum_order) as sort_max FROM ".$table_forums." WHERE forum_category=".mysql_real_escape_string($values['forum_category']);
-	$result=api_sql_query($sql);
-	$row=mysql_fetch_array($result);
-	$new_max=$row['sort_max']+1;
-
-	
-	$sql="INSERT INTO ".$table_forums." 
-				(forum_title, forum_comment, forum_category, allow_anonymous, allow_edit, approval_direct_post, allow_attachments, allow_new_threads, default_view, forum_of_group, forum_group_public_private, forum_order) 
-				VALUES ('".mysql_real_escape_string($values['forum_title'])."',
-					'".mysql_real_escape_string($values['forum_comment'])."',
-					'".mysql_real_escape_string($values['forum_category'])."',
-					'".mysql_real_escape_string($values['allow_anonymous_group']['allow_anonymous'])."',
-					'".mysql_real_escape_string($values['students_can_edit_group']['students_can_edit'])."',
-					'".mysql_real_escape_string($values['approval_direct_group']['approval_direct'])."',
-					'".mysql_real_escape_string($values['allow_attachments_group']['allow_attachments'])."',
-					'".mysql_real_escape_string($values['allow_new_threads_group']['allow_new_threads'])."', 
-					'".mysql_real_escape_string($values['default_view_type_group']['default_view_type'])."', 
-					'".mysql_real_escape_string($values['group_forum'])."', 
-					'".mysql_real_escape_string($values['public_private_group_forum_group']['public_private_group_forum'])."', 
-					'".mysql_real_escape_string($new_max)."')";
-	api_sql_query($sql, __LINE__,__FILE__); 
-	$last_id=mysql_insert_id();
-	api_item_property_update($_course, TOOL_FORUM, $last_id,"ForumCategoryAdded", $_user['user_id']);
-	return array('id'=>$last_id, 'title'=>$values['forum_title']);
-}
-
-/**
-* This function stores a new thread. This is done through an entry in the forum_thread table AND 
-* in the forum_post table because. The threads are also stored in the item_property table. (forum posts are not (yet))
-* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
-*/
-function store_thread($values)
-{
-	global $table_threads; 
-	global $table_posts; 
-	global $_user; 
-	global $_course; 
-	global $current_forum; 
-	
-	// We first store an entry in the forum_thread table because the thread_id is used in the forum_post table
-	$sql="INSERT INTO $table_threads (thread_title, forum_id, thread_poster_id, thread_poster_name, thread_views, thread_date, thread_sticky) 
-			VALUES ('".mysql_real_escape_string($values['post_title'])."',
-					'".mysql_real_escape_string($values['forum_id'])."',
-					'".mysql_real_escape_string($values['user_id'])."', 
-					'".mysql_real_escape_string($values['poster_name'])."', 
-					'".mysql_real_escape_string($values['topic_views'])."', 
-					'".mysql_real_escape_string($values['post_date'])."',
-					'".mysql_real_escape_string($values['thread_sticky'])."')";
-	$result=api_sql_query($sql, __LINE__, __FILE__);
-	$last_thread_id=mysql_insert_id();
-	api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"ForumThreadAdded", $_user['user_id']);
-	// if the forum properties tell that the posts have to be approved we have to put the whole thread invisible
-	// because otherwise the students will see the thread and not the post in the thread. 
-	// we also have to change $visible because the post itself has to be visible in this case (otherwise the teacher would have 
-	// to make the thread visible AND the post
-	if ($values['visible']==0)
-	{
-		api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"invisible", $_user['user_id']);
-		$visible=1;
-	}
-
-	return $last_thread_id; 
-}
-
-/**
-* This function migrates the threads of a given phpbb forum to a new forum of the new forum tool
-* @param $phpbb_forum_id the forum_id of the old (phpbb) forum
-* @param $new_forum_id the forum_id in the new forum
-* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
-*/
-function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id)
-{
-	global $phpbb_threads; 
-	global $table_forums; 
-	
-	$table_users = Database :: get_main_table(TABLE_MAIN_USER);
-	
-	$sql_phpbb_threads="SELECT forum.*, users.user_id 
-							FROM $phpbb_threads forum, $table_users users 
-							WHERE forum_id='".mysql_real_escape_string($phpbb_forum_id)."' 
-							AND forum.nom=users.lastname AND forum.prenom=users.firstname
-							";
-	$result_phpbb_threads=api_sql_query($sql_phpbb_threads);
-	$threads_counter=0;
-	while ($row_phpbb_threads=mysql_fetch_array($result_phpbb_threads))
-	{
-		$values['post_title']=$row_phpbb_threads['topic_title']; 
-		$values['forum_id']=$new_forum_id;
-		$values['user_id']=$row_phpbb_threads['user_id'];
-		$values['poster_name']=0;
-		$values['topic_views']=$row_phpbb_threads['topic_views'];
-		$values['post_date']=$row_phpbb_threads['topic_time'];
-		$values['thread_sticky']=0;
-		$values['visible']=$row_phpbb_threads['visible'];
-		//my_print_r($values);
-		$new_forum_thread_id=store_thread($values);
-		
-		// now we migrate the posts of the given thread
-		$posts_counter=$posts_counter+migrate_posts_of_thread($row_phpbb_threads['topic_id'], $new_forum_thread_id, $new_forum_id);
-		
-		$threads_counter++;
-	}
-	
-	// Now we update the forum_forum table with the total number of posts for the given forum.
-	$sql="UPDATE $table_forums 
-			SET forum_posts='".mysql_real_escape_string($posts_counter)."',
-			forum_threads='".mysql_real_escape_string($threads_counter)."' 
-			WHERE forum_id='".mysql_real_escape_string($new_forum_id)."'";
-	//echo $sql; 
-	$result=api_sql_query($sql);
-	return array("threads"=>$threads_counter, "posts"=>$posts_counter);
-}
-
-/**
-* This function migrates the posts of a given phpbb thread (topic) to a thread in the new forum tool
-* @param $phpbb_forum_id the forum_id of the old (phpbb) forum
-* @param $new_forum_id the forum_id in the new forum
-* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
-*/
-function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_forum_id)
-{
-	global $phpbb_posts;
-	global $phpbb_poststext; 
-	global $table_posts; 
-	global $table_threads; 
-	global $added_resources; 
-	
-	$table_users = Database :: get_main_table(TABLE_MAIN_USER);
-	$table_added_resources = Database::get_course_table(TABLE_LINKED_RESOURCES);
-	
-	
-	$post_counter=0;
-	
-	$sql_phpbb_posts="SELECT posts.*, posts_text.*, users.user_id, users.lastname, users.firstname FROM $phpbb_posts posts, $phpbb_poststext posts_text, $table_users users 
-						WHERE posts.post_id=posts_text.post_id
-						AND posts.nom=users.lastname 
-						AND posts.prenom=users.firstname
-						AND posts.topic_id='".mysql_real_escape_string($phpbb_thread_id)."'
-						";
-	$result_phpbb_posts=api_sql_query($sql_phpbb_posts);
-	while($row_phpbb_posts=mysql_fetch_array($result_phpbb_posts))
-	{
-		$values=array();
-		$values['post_title']=$row_phpbb_posts['post_title'];
-		$values['post_text']=$row_phpbb_posts['post_text'];
-		$values['thread_id']=$new_forum_thread_id;
-		$values['forum_id']=$new_forum_id; 
-		$values['user_id']=$row_phpbb_posts['user_id']; 
-		$values['post_date']=$row_phpbb_posts['post_time'];
-		$values['post_notification']=$row_phpbb_posts['topic_notify'];
-		$values['post_parent_id']=0; 
-		$values['visible']=1;		
-	
-		// We first store an entry in the forum_post table
-		$sql="INSERT INTO $table_posts (post_title, post_text, thread_id, forum_id, poster_id,  post_date, post_notification, post_parent_id, visible) 
-				VALUES ('".mysql_real_escape_string($values['post_title'])."',
-						'".mysql_real_escape_string($values['post_text'])."',
-						'".mysql_real_escape_string($values['thread_id'])."',
-						'".mysql_real_escape_string($values['forum_id'])."',
-						'".mysql_real_escape_string($values['user_id'])."',
-						'".mysql_real_escape_string($values['post_date'])."',
-						'".mysql_real_escape_string($values['post_notification'])."',
-						'".mysql_real_escape_string($values['post_parent_id'])."',
-						'".mysql_real_escape_string($values['visible'])."')";
-		$result=api_sql_query($sql, __LINE__, __FILE__);
-		$post_counter++;
-		$last_post_id=mysql_insert_id();
-		
-		
-		// We check if there added resources and if so we update them
-		if (in_array($row_phpbb_posts['post_id'],$added_resources))
-		{
-			$sql_update_added_resource="UPDATE $table_added_resources 
-					SET source_type='forum_post', source_id='".mysql_real_escape_string($last_post_id)."'
-					WHERE source_type='".mysql_real_escape_string(TOOL_BB_POST)."' AND source_id='".mysql_real_escape_string($row_phpbb_posts['post_id'])."'";
-			echo $sql_update_added_resource;
-			$result=api_sql_query($sql_update_added_resource, __LINE__, __FILE__);
-		}
-
-
-	}
-	
-	// update the thread_last_post of the post table AND the 
-	$sql="UPDATE $table_threads SET thread_last_post='".mysql_real_escape_string($last_post_id)."', 
-			thread_replies='".mysql_real_escape_string($post_counter-1)."'
-			WHERE thread_id='".mysql_real_escape_string($new_forum_thread_id)."'";
-	//echo $sql; 
-	$result=api_sql_query($sql, __LINE__, __FILE__);
-	//echo $sql; 
-	return $post_counter; 
-}
-
-/**
-* This function gets all the added resources for phpbb forum posts
-* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
-*/
-function get_added_resources()
-{
-	$table_added_resources = Database::get_course_table(TABLE_LINKED_RESOURCES);
-	$return_array=array();
-
-	// TODO: now we also migrate the added resources. 
-	$sql_added_resources="SELECT * FROM $table_added_resources WHERE source_type='".mysql_real_escape_string(TOOL_BB_POST)."'";
-	$result=api_sql_query($sql_added_resources);
-	while ($row=mysql_fetch_array($result))
-	{
-		$return_array[]=$row['source_id'];
-	}
-	return $return_array;
-}
-
-/**
-* This function gets the forum category information based on the name 
-* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
-* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
-*/
-function get_forumcategory_id_by_name($forum_category_name)
-{
-	global $table_categories;
-	
-	$sql="SELECT cat_id FROM $table_categories WHERE cat_title='".mysql_real_escape_string($forum_category_name)."'";
-	//echo $sql; 
-	$result=api_sql_query($sql,__LINE__,__FILE__);
-	$row=mysql_fetch_array($result);
-	//echo $row['cat_id'];
-	return $row['cat_id'];
-}
 ?>