3 * FusionForge rate user page
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 (c) Franck Villaume
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once '../env.inc.php';
25 require_once $gfcommon.'include/pre.php';
26 require_once $gfwww.'include/vote_function.php';
28 if (!session_loggedin()) {
32 $me =& session_get_user();
33 if (!$me->usesRatings()) {
34 exit_error(_('Ratings turned off. You chose not to participate in the peer rating system'),'my');
37 $rated_user = getStringFromRequest('rated_user');
38 $ruser = $me->getID();
39 if ($rated_user != $ruser) {
40 //how many questions can they be rated on?
41 $count=count($USER_RATING_QUESTIONS);
43 //now iterate and insert each response
44 for ($i=1; $i<=$count; $i++) {
46 $rating = getStringFromRequest($resp);
48 //unrated on this criteria
50 //ratings can only be between +3 and -3
51 if ($rating > 3 || $rating < -3) {
52 $warning_msg .= _('Invalid rate value');
55 // get rid of 0.1 thing
56 $rating = (int)$rating;
57 //user did answer this question, so insert into db
58 $res=db_query_params ('SELECT * FROM user_ratings WHERE rated_by=$1 AND user_id=$2 AND rate_field=$3',
63 if ($res && db_numrows($res) > 0) {
64 $res=db_query_params ('DELETE FROM user_ratings WHERE rated_by=$1 AND user_id=$2 AND rate_field=$3',
70 $res=db_query_params ('INSERT INTO user_ratings (rated_by,user_id,rate_field,rating) VALUES ($1,$2,$3,$4)',
77 exit_error(db_error(),'my');
84 exit_error(_('You can\'t rate yourself'),'my');
87 echo $HTML->header(array('title'=>_('User Ratings Page')));
90 <h3>'._('Ratings Recorded').'</h3>
91 <p>'._('You can re-rate this person by simply returning to their ratings page and re-submitting the info.').'.</p>
94 echo $HTML->footer(array());