Esempio n. 1
0
 /**
  * Return counter single client has votes this debate
  *
  * @return int
  */
 public function getUserVoteCount()
 {
     if ($this->m_data['allow_not_logged_in']) {
         $key = 'debate_' . $this->m_data['fk_language_id'] . '_' . $this->m_data['debate_nr'];
         if (array_key_exists($key, $_COOKIE)) {
             return $_COOKIE[$key];
         }
         if (array_key_exists($key, $_SESSION)) {
             return $_SESSION[$key];
         }
     } else {
         if (is_null($this->userId)) {
             return false;
         }
         $votes = DebateVote::getUserVotes($this->m_data['debate_nr'], $this->userId);
         if (empty($votes)) {
             return 0;
         }
         $total = 0;
         foreach ($votes as $vote) {
             $total += $vote;
         }
         return $total;
     }
     return 0;
 }