From 75a177106e82477053bdde2d9eaeed351b892500 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 9 Sep 2007 21:20:55 +0200 Subject: [PATCH] Close #710: Grade administration would corrupt the grade table Signed-off-by: Florent Bruneau --- ChangeLog | 1 + modules/profile.php | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47b3242..1c0c99d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -34,6 +34,7 @@ Bug/Wish: - #692: Layout of the profile -FRU - #693: Fix empty description for generic education -FRU - #708: Fix title (fix by Laurent Penou from Gadz.org) -FRU + - #710: Adding grade do not degrade the database -FRU * Xnet: - #694: Color of 'Promotion' groups -ALK diff --git a/modules/profile.php b/modules/profile.php index abf5de5..e4fb63f 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -778,13 +778,17 @@ class ProfileModule extends PLModule $mid = $id; if (Post::v('act') == 'del') { - XDB::execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post::i('gid')); + XDB::execute('DELETE FROM profile_medals_grades + WHERE mid={?} AND gid={?}', $mid, Post::i('gid')); } elseif (Post::v('act') == 'new') { - XDB::execute('INSERT INTO profile_medals_grades (mid,gid) VALUES({?},{?})', + XDB::execute('INSERT INTO profile_medals_grades (mid,gid) + VALUES ({?},{?})', $mid, max(array_keys(Post::v('grades', array(0))))+1); } else { foreach (Post::v('grades', array()) as $gid=>$text) { - XDB::execute('UPDATE profile_medals_grades SET pos={?}, text={?} WHERE gid={?}', $_POST['pos'][$gid], $text, $gid); + XDB::execute('UPDATE profile_medals_grades + SET pos={?}, text={?} + WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid); } } $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid); -- 2.1.4