Skip to content
Browse files

bug fix

  • Loading branch information...
1 parent ddae291 commit ccd1707e1ce68584969af5216967a6a6506db4a5 @cs278 cs278 committed Jul 14, 2009
Showing with 23 additions and 19 deletions.
  1. +23 −19 includes/classes/voter.php
View
42 includes/classes/voter.php
@@ -181,34 +181,38 @@ public static function get($id)
public function __get($var)
{
- if (!isset($this->$var))
+ if (isset($this->$var))
{
- return null;
+ return $this->$var;
}
- if ($var == 'points' && $this->$var === null)
+ switch ($var)
{
- $this->points = $this->base_points;
+ case 'points':
+ global $db;
+
+ $this->points = $this->base_points;
- $sql = 'SELECT SUM(vote_cost) AS cost
- FROM ' . vote::TABLE . "
- WHERE user_id = {$this->id}
- GROUP BY user_id";
+ $sql = 'SELECT SUM(vote_cost) AS cost
+ FROM ' . vote::TABLE . "
+ WHERE user_id = {$this->id}
+ GROUP BY user_id";
- $result = $db->sql_query($sql);
- $this->points -= (int) $db->sql_fetchfield('cost', false, $result);
- $db->sql_freeresult($result);
+ $result = $db->sql_query($sql);
+ $this->points -= (int) $db->sql_fetchfield('cost', false, $result);
+ $db->sql_freeresult($result);
- $sql = 'SELECT SUM(idea_cost) AS cost
- FROM ' . idea::TABLE . "
- WHERE user_id = {$this->id}
- GROUP BY user_id";
+ $sql = 'SELECT SUM(idea_cost) AS cost
+ FROM ' . idea::TABLE . "
+ WHERE user_id = {$this->id}
+ GROUP BY user_id";
- $result = $db->sql_query($sql);
- $this->points -= (int) $db->sql_fetchfield('cost', false, $result);
- $db->sql_freeresult($result);
+ $result = $db->sql_query($sql);
+ $this->points -= (int) $db->sql_fetchfield('cost', false, $result);
+ $db->sql_freeresult($result);
+ break;
}
- return $this->$var;
+ return (isset($this->$var)) ? $this->$var : null;
}
}

0 comments on commit ccd1707

Please sign in to comment.
Something went wrong with that request. Please try again.