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