diff options
Diffstat (limited to 'includes/wot.inc.php')
-rw-r--r-- | includes/wot.inc.php | 116 |
1 files changed, 73 insertions, 43 deletions
diff --git a/includes/wot.inc.php b/includes/wot.inc.php index ce35ed6..884b97f 100644 --- a/includes/wot.inc.php +++ b/includes/wot.inc.php @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ +*/ function query_init ($query) { @@ -35,7 +35,7 @@ function get_number_of_assurances ($userid) { $res = query_init ("SELECT count(*) AS `list` FROM `notary` - WHERE `notary`.`from` != `notary`.`to` AND `notary`.`from`='".intval($userid)."'"); + WHERE `method` = 'Face to Face Meeting' AND `from`='".intval($userid)."' "); $row = query_getnextrow($res); return intval($row['list']); @@ -44,7 +44,7 @@ function get_number_of_assurees ($userid) { $res = query_init ("SELECT count(*) AS `list` FROM `notary` - WHERE `notary`.`from` != `notary`.`to` AND `notary`.`to`='".intval($userid)."'"); + WHERE `method` = 'Face to Face Meeting' AND `to`='".intval($userid)."' "); $row = query_getnextrow($res); return intval($row['list']); @@ -52,39 +52,41 @@ function get_top_assurer_position ($no_of_assurances) { - $res = query_init ("SELECT count(*) AS `list` FROM `notary` - GROUP BY `notary`.`from` HAVING count(*) > '".intval($no_of_assurances)."'"); + $res = query_init ("SELECT count(*) AS `list` FROM `notary` + WHERE `method` = 'Face to Face Meeting' + GROUP BY `from` HAVING count(*) > '".intval($no_of_assurances)."'"); return intval(query_get_number_of_rows($res)+1); } function get_top_assuree_position ($no_of_assurees) { $res = query_init ("SELECT count(*) AS `list` FROM `notary` - GROUP BY `notary`.`to` HAVING count(*) > '".intval($no_of_assurees)."'"); + WHERE `method` = 'Face to Face Meeting' + GROUP BY `to` HAVING count(*) > '".intval($no_of_assurees)."'"); return intval(query_get_number_of_rows($res)+1); } function get_given_assurances ($userid) { - $res = query_init ("select * from `notary` where `notary`.`from`='".intval($userid)."' and `notary`.`from` != `to` order by `notary`.`id` asc"); + $res = query_init ("select * from `notary` where `from`='".intval($userid)."' and `from` != `to` order by `id` asc"); return $res; } function get_received_assurances ($userid) { - $res = query_init ("select * from `notary` where `notary`.`to`='".intval($userid)."' and `notary`.`from` != `notary`.`to` order by `notary`.`id` asc "); + $res = query_init ("select * from `notary` where `to`='".intval($userid)."' and `from` != `to` order by `id` asc "); return $res; } function get_given_assurances_summary ($userid) { - $res = query_init ("select count(*) as number,points,awarded,method from notary where `notary`.`from`='".intval($userid)."' group by points,awarded,method"); + $res = query_init ("select count(*) as number,points,awarded,method from notary where `from`='".intval($userid)."' group by points,awarded,method"); return $res; } - + function get_received_assurances_summary ($userid) { - $res = query_init ("select count(*) as number,points,awarded,method from notary where `notary`.`to`='".intval($userid)."' group by points,awarded,method"); + $res = query_init ("select count(*) as number,points,awarded,method from notary where `to`='".intval($userid)."' group by points,awarded,method"); return $res; } @@ -104,14 +106,17 @@ function calc_experience ($row,&$points,&$experience,&$sum_experience) { - $points += $row['awarded']; + $apoints = max($row['points'], $row['awarded']); + + $points += $apoints; + $experience = " "; if ($row['method'] == "Face to Face Meeting") { $sum_experience = $sum_experience +2; $experience = "2"; } - return $row['awarded']; + return $apoints; } function calc_assurances ($row,&$points,&$experience,&$sumexperience,&$awarded) @@ -124,7 +129,7 @@ $awarded = 100; } else - $experience = 0; + $experience = 0; switch ($row['method']) { @@ -145,7 +150,12 @@ { $name = trim($name); if($name == "") - $name = _("Deleted before Verification"); + { + if ($userid == 0) + $name = _("System"); + else + $name = _("Deleted account"); + } else $name = "<a href='wot.php?id=9&userid=".intval($userid)."'>$name</a>"; return $name; @@ -221,17 +231,35 @@ <? } - function output_assurances_row($assuranceid,$date,$name,$points,$location,$method,$experience) + function output_assurances_row($assuranceid,$date,$when,$name,$awarded,$points,$location,$method,$experience) + { + + $tdstyle=""; + $emopen=""; + $emclose=""; + + if ($awarded == $points) { + if ($awarded == "0") + { + if ($when < "2006-09-01") + { + $tdstyle="style='background-color: #ffff80'"; + $emopen="<em>"; + $emclose="</em>"; + } + } + } + ?> <tr> - <td class="DataTD"><?=$assuranceid?></td> - <td class="DataTD"><?=$date?></td> - <td class="DataTD"><?=$name?></td> - <td class="DataTD"><?=$points?></td> - <td class="DataTD"><?=$location?></td> - <td class="DataTD"><?=$method?></td> - <td class="DataTD"><?=$experience?></td> + <td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$assuranceid?><?=$emclose?></td> + <td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$date?><?=$emclose?></td> + <td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$name?><?=$emclose?></td> + <td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$awarded?><?=$emclose?></td> + <td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$location?><?=$emclose?></td> + <td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$method?><?=$emclose?></td> + <td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$experience?><?=$emclose?></td> </tr> <? } @@ -272,15 +300,6 @@ <? } - function output_cats_needed() - { -?> - <tr> - <td class="DataTD" colspan=4><strong style='color: red'><?=_("You have to pass the CAcert Assurer Challenge (CATS-Test) to be an Assurer")?></strong></td> - </tr> -<? - } - // ************* output given assurances ****************** @@ -291,10 +310,10 @@ $res = get_given_assurances(intval($userid)); while($row = mysql_fetch_assoc($res)) { - $fromuser = get_user (intval($row['to'])); - calc_experience ($row,$points,$experience,$sum_experience); + $fromuser = get_user (intval($row['to'])); + $apoints = calc_experience ($row,$points,$experience,$sum_experience); $name = show_user_link ($fromuser['fname']." ".$fromuser['lname'],intval($row['to'])); - output_assurances_row (intval($row['id']),$row['date'],$name,intval($row['awarded']),$row['location'],$row['method']==""?"":_(sprintf("%s", $row['method'])),$experience); + output_assurances_row (intval($row['id']),$row['date'],$row['when'],$name,$apoints,intval($row['points']),$row['location'],$row['method']==""?"":_(sprintf("%s", $row['method'])),$experience); } } @@ -309,8 +328,8 @@ { $fromuser = get_user (intval($row['from'])); calc_assurances ($row,$points,$experience,$sum_experience,$awarded); - $name = show_user_link ($fromuser['fname']." ".$fromuser['lname'],intval($row['to'])); - output_assurances_row (intval($row['id']),$row['date'],$name,$awarded,$row['location'],$row['method']==""?"":_(sprintf("%s", $row['method'])),$experience); + $name = show_user_link ($fromuser['fname']." ".$fromuser['lname'],intval($row['from'])); + output_assurances_row (intval($row['id']),$row['date'],$row['when'],$name,$awarded,intval($row['points']),$row['location'],$row['method']==""?"":_(sprintf("%s", $row['method'])),$experience); } } @@ -325,8 +344,11 @@ function calc_points($row) { - if (intval($row['points']) < intval($row['awarded'])) - $points = intval($row['awarded']); // if 'sum of added points' > 100, awarded shows correct value + $awarded = intval($row['awarded']); + if ($awarded == "") + $awarded = 0; + if (intval($row['points']) < $awarded) + $points = $awarded; // if 'sum of added points' > 100, awarded shows correct value else $points = intval($row['points']); // on very old assurances, awarded is '0' instead of correct value switch ($row['method']) @@ -340,8 +362,8 @@ if ($points <= 2) // maybe limit to 35/50 pts in the future? $points = 0; break; - case 'unknown': // to be revoked in the future? limit to max 50 pts? - case 'Trusted 3rd Parties': // to be revoked in the future? limit to max 35 pts? + case 'Unknown': // to be revoked in the future? limit to max 50 pts? + case 'Trusted Third Parties': // to be revoked in the future? limit to max 35 pts? case '': // to be revoked in the future? limit to max 50 pts? case 'Face to Face Meeting': // normal assurances, limit to 35/50 pts in the future? break; @@ -412,7 +434,7 @@ else { $sum_points_countable = $sum_points; - $remark_points = " "; + $remark_points = " "; } if ($sum_experience > $max_experience) { @@ -439,7 +461,7 @@ if ($sum_points_countable < $max_points) { if ($sum_experience_countable != 0) - $remark_experience = $points_on_hold_txt;_("Points on hold due to less assurance points"); + $remark_experience = _("Points on hold due to less assurance points"); $sum_experience_countable = 0; if ($sum_experience_other_countable != 0) $remark_experience_other = _("Points on hold due to less assurance points"); @@ -449,7 +471,15 @@ $issue_points = 0; $cats_test_passed = get_cats_state ($userid); if ($cats_test_passed == 0) + { $issue_points_txt = "<strong style='color: red'>"._("You have to pass the CAcert Assurer Challenge (CATS-Test) to be an Assurer")."</strong>"; + if ($sum_points_countable < $max_points) + { + $issue_points_txt = "<strong style='color: red'>"; + $issue_points_txt .= sprintf(_("You need %s assurance points and the passed CATS-Test to be an Assurer"), intval($max_points)); + $issue_points_txt .= "</strong>"; + } + } else { $experience_total = $sum_experience_countable+$sum_experience_other_countable; |