Merge branch 'bug-1391'

bug-1396
Benny Baumann 9 years ago
commit 733814fd08

@ -66,7 +66,7 @@ class Default_Model_User {
public function findNewAssurer()
{
$query = 'select min(`id`) as `assurer` from `users` ' .
'where `email` like \'john.doe-___@example.com\' and ' .
'where `email` like \'john.doe-___@example.com\' and ' .
'`id` not in (select `from` from `notary` where `to` = :user)';
$query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch();
@ -87,7 +87,7 @@ class Default_Model_User {
*/
public function findNewAssuree() {
$query = 'select min(`id`) as `assuree` from `users` ' .
'where `email` like \'john.doe-___@example.com\' and ' .
'where `email` like \'john.doe-___@example.com\' and ' .
'`id` not in (select `to` from `notary` where `from` = :user)';
$query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch();
@ -108,8 +108,8 @@ class Default_Model_User {
* user's points
*/
public function refreshPoints() {
$query = "select sum(`points`) as `total` from `notary` " .
"where `to` = :user and method != 'Administrative Increase' and from != to";
$query = "SELECT SUM(`points`) AS `total` FROM `notary` " .
"WHERE `to` = :user AND `method` != 'Administrative Increase' AND `from` != `to`";
$query_params['user'] = $this->id;
$row = $this->db->query($query, $query_params)->fetch();
if ($row['total'] === null) $row['total'] = 0;
@ -117,7 +117,7 @@ class Default_Model_User {
$this->points = $row['total'];
}
/**
/**
* Get points of the user
*
* @return int
@ -137,7 +137,7 @@ class Default_Model_User {
*/
public function fixAssurerFlag()
{
// TODO: unset flag if requirements are not met
// TODO: unset flag if requirements are not met
$query = 'UPDATE `users` SET `assurer` = 1 WHERE `users`.`id` = :user AND '.
@ -156,11 +156,11 @@ class Default_Model_User {
*/
public function getAssurerStatus() {
$query = 'SELECT 1 FROM `users` WHERE `users`.`id` = :user AND '.
'`assurer_blocked` = 0 AND '.
'`assurer_blocked` = 0 AND '.
'EXISTS(SELECT * FROM `cats_passed` AS `cp`, `cats_variant` AS `cv` '.
'WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND '.
'`cp`.`user_id` = :user) AND '.
'EXISTS(SELECT * FROM `cats_passed` AS `cp`, `cats_variant` AS `cv` '.
'WHERE `cp`.`variant_id` = `cv`.`id` AND `cv`.`type_id` = 1 AND '.
'`cp`.`user_id` = :user) AND '.
'(SELECT SUM(`points`) FROM `notary` WHERE `to` = :user AND '.
'`expire` < now()) >= 100';
@ -195,7 +195,7 @@ class Default_Model_User {
// Did we have a happy birthday already this year?
$dob->setYear($now);
if ($dob->compare($now) > 0) {
$age -= 1;
$age -= 1;
}
return $age;
@ -225,8 +225,7 @@ class Default_Model_User {
* The amount of points that have been issued (might be less than
* $points)
*/
public function assure(Default_Model_User $assuree, $points, $location,
$date) {
public function assure(Default_Model_User $assuree, $points, $location, $date) {
// Sanitize inputs
$points = intval($points);
$location = stripslashes($location);
@ -245,7 +244,7 @@ class Default_Model_User {
}
$query = 'select * from `notary` where `from`= :assurer and '.
'`to`= :assuree';
'`to`= :assuree';
$query_params['assurer'] = $this->id;
$query_params['assuree'] = $assuree->id;
$result = $this->db->query($query, $query_params);
@ -270,8 +269,8 @@ class Default_Model_User {
if ($rounddown < 0) $rounddown = 0;
$query = 'select * from `notary` where `from` = :assurer and '.
'`to` = :assuree and `awarded` = :points and '.
'`location` = :location and `date` = :date';
'`to` = :assuree and `awarded` = :points and '.
'`location` = :location and `date` = :date';
$query_params['assurer'] = $this->id;
$query_params['assuree'] = $assuree->id;
$query_params['points'] = $points;

Loading…
Cancel
Save