Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
28 views
in Q2A Core by

Below is the code from db/recalc.php (I have removed the lines for External Users to make it easier to read). My question is why are the userdata being deleted from userpoints and then added from qa_users data? Points are anyway being recalculated and so what is the issue for letting the userdata in the userpoints be the same as it will be overwritten after recalculation? The issue with the current approach is that if qa_users table is shared, this recalc will copy all the user data from the Network of sites to the current site. Is it safe to remove the delete? 

 qa_db_query_sub(

                'DELETE FROM ^userpoints WHERE userid>=# AND userid<=# AND bonus=0', // delete those with no bonus

                $firstuserid, $lastuserid

        );

        $zeropoints = 'points=0';

        foreach ($qa_userpoints_calculations as $field => $calculation) {

                $zeropoints .= ', ' . $field . '=0';

        }

        qa_db_query_sub(

                'UPDATE ^userpoints SET ' . $zeropoints . ' WHERE userid>=# AND userid<=#', // zero out the rest

                $firstuserid, $lastuserid

        );

                qa_db_query_sub(

                        'INSERT IGNORE INTO ^userpoints (userid) SELECT DISTINCT userid FROM ^users WHERE userid>=# AND userid<=#',

                        $firstuserid, $lastuserid

                );

        }

Q2A version: 1.8

Please log in or register to answer this question.

...