Ignore:
Timestamp:
2006/12/12 23:43:18 (20 years ago)
Author:
uehara
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • temp/test-xoops.ec-cube.net/html/modules/xoopspoll/class/xoopspolllog.php

    r405 r770  
    4545        $this->initVar("user_id", XOBJ_DTYPE_INT, 0); 
    4646        $this->initVar("time", XOBJ_DTYPE_INT, null); 
     47        $this->initVar("rating_id", XOBJ_DTYPE_INT, null); 
     48        $this->initVar("comment", XOBJ_DTYPE_TXTAREA, null); 
    4749        if ( !empty($id) ) { 
    4850            if ( is_array($id) ) { 
     
    6365            $$k = $v; 
    6466        } 
     67 
    6568        $log_id = $this->db->genId($this->db->prefix("xoopspoll_log")."_log_id_seq"); 
    66         $sql = "INSERT INTO ".$this->db->prefix("xoopspoll_log")." (log_id, poll_id, option_id, ip, user_id, time) VALUES ($log_id, $poll_id, $option_id, ".$this->db->quoteString($ip).", $user_id, ".time().")"; 
     69        $sql = "INSERT INTO ".$this->db->prefix("xoopspoll_log")." (log_id, poll_id, option_id, ip, user_id, time, rating_id, comment) VALUES ($log_id, $poll_id, $option_id, ".$this->db->quoteString($ip).", $user_id, ".time().", $rating_id, ".$this->db->quoteString($comment).")"; 
    6770        $result = $this->db->query($sql); 
    6871        if (!$result) { 
     
    148151    { 
    149152        $db =& Database::getInstance(); 
    150         $sql = "SELECT DISTINCT user_id FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id)." AND user_id > 0"; 
     153        $sql = "SELECT DISTINCT user_id FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id)." AND user_id > 0 AND rating_id = 1"; 
    151154        $users = $db->getRowsNum($db->query($sql)); 
    152         $sql = "SELECT DISTINCT ip FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id)." AND user_id=0"; 
     155        $sql = "SELECT DISTINCT ip FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id)." AND user_id=0 AND rating_id = 1"; 
    153156        $anons = $db->getRowsNum($db->query($sql)); 
    154157        return $users+$anons; 
     
    159162    { 
    160163        $db =& Database::getInstance(); 
    161         $sql = "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id = ".intval($poll_id); 
     164        $sql = "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id = ".intval($poll_id)." AND rating_id = 1"; 
    162165        list($votes) = $db->fetchRow($db->query($sql)); 
    163166        return $votes; 
     
    165168 
    166169    // public static 
    167     function getTotalVotesByOptionId($option_id) 
     170    function getTotalVotesByOptionId($option_id, $rating_id) 
    168171    { 
    169172        $db =& Database::getInstance(); 
    170         $sql = "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE option_id = ".intval($option_id); 
     173        $sql = "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE option_id = ".intval($option_id)." AND rating_id = $rating_id"; 
    171174        list($votes) = $db->fetchRow($db->query($sql)); 
    172175        return $votes; 
Note: See TracChangeset for help on using the changeset viewer.