Close #710: Grade administration would corrupt the grade table
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 9 Sep 2007 19:20:55 +0000 (21:20 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 9 Sep 2007 19:20:55 +0000 (21:20 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
ChangeLog
modules/profile.php

index 47b3242..1c0c99d 100644 (file)
--- 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
index abf5de5..e4fb63f 100644 (file)
@@ -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);