From 9d54532b3ef8dd14a7cc2df9262e0e6da8a2592d Mon Sep 17 00:00:00 2001 From: Eric Marguin Date: Tue, 22 Jan 2008 12:14:26 +0100 Subject: [PATCH] [svn r14165] fill the sort field of user_course_category --- main/install/update-db-1.6.x-1.8.0.inc.php | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/main/install/update-db-1.6.x-1.8.0.inc.php b/main/install/update-db-1.6.x-1.8.0.inc.php index a4865acbf3..46ef0d46e4 100755 --- a/main/install/update-db-1.6.x-1.8.0.inc.php +++ b/main/install/update-db-1.6.x-1.8.0.inc.php @@ -613,6 +613,31 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) } } + // upgrade user categories sort + $table_user_categories = Database :: get_user_personal_table(TABLE_USER_COURSE_CATEGORY); + + + $sql = 'SELECT * FROM '.$table_user_categories.' ORDER BY user_id, title'; + + $rs = api_sql_query($sql, __FILE__, __LINE__); + + $sort = 0; + $old_user = 0; + while($cat = Database :: fetch_array($rs)) + { + if($old_user != $cat['user_id']) + { + $old_user = $cat['user_id']; + $sort = 0; + } + $sort++; + $sql = 'UPDATE '.$table_user_categories.' SET + sort = '.intval($sort).' + WHERE id='.intval($cat['id']); + api_sql_query($sql, __FILE__, __LINE__); + } + + } else {