Changeset 777 for temp


Ignore:
Timestamp:
2006/12/13 00:46:45 (20 years ago)
Author:
uehara
Message:
 
Location:
temp/test-xoops.ec-cube.net/html/modules/xoopspoll
Files:
3 edited

Legend:

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

    r770 r777  
    200200        $this->db->query($sql); 
    201201    } 
     202 
     203    // public 
     204    function insertOption($arrData) 
     205    { 
     206        $option_text = str_replace("'", "''", $arrData['title']); 
     207        $body = str_replace("'", "''", $arrData['body']); 
     208        $sql ="INSERT INTO ".$this->db->prefix("xoopspoll_option")." (poll_id, option_text, body, status, category_id, update_date) ". 
     209                "VALUES (".$arrData['poll_id'].", ".$option_text.", ".$body.", 1, ".$arrData['category_id'].", now())"; 
     210         
     211                $this->db->query($sql); 
     212    }    
    202213} 
    203214?> 
  • temp/test-xoops.ec-cube.net/html/modules/xoopspoll/pollnew.php

    r774 r777  
    3333include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspollrenderer.php"; 
    3434 
     35$arrForm = $_POST; 
     36 
    3537$poll_id = $_GET['poll_id']; 
    36 if(empty($poll_id)) $poll_id = $_POST['poll_id']; 
     38if(empty($poll_id)) $poll_id = $arrForm['poll_id']; 
    3739 
    3840switch($_POST['mode']) { 
    3941    case 'regist': 
    40         $poll_id = $_POST['poll_id']; 
    41         $poll = new XoopsPoll($poll_id); 
    42         if ( $xoopsUser ) { 
    43             $uid = $xoopsUser->getVar("uid"); 
    44         } else { 
    45             $uid = 0; 
     42        // Error Check 
     43        $arrErr = lfErrCheck(); 
     44        if(count($arrErr) <= 0) { 
     45            $poll = new XoopsPoll($poll_id); 
     46            $poll->insertOption($arrForm); 
     47            redirect_header(XOOPS_URL."/modules/xoopspoll/pollresults.php?poll_id=".$poll_id, 1, "ÅÐÏ¿¤¬´°Î»Ãפ·¤Þ¤·¤¿¡£"); 
     48            exit(); 
    4649        } 
    47         $poll->vote($option_id, xoops_getenv('REMOTE_ADDR'), $uid, $_POST['rating_id'], $_POST['comment']); 
    48         $poll->updateCount(); 
    49         redirect_header(XOOPS_URL."/modules/xoopspoll/pollresults.php?poll_id=".$poll_id, 1, $msg); 
    50         exit(); 
    5150        break; 
    5251    default: 
     
    5756include XOOPS_ROOT_PATH."/header.php"; 
    5857 
     58$xoopsTpl->assign('arrForm', $arrForm); 
     59$xoopsTpl->assign('arrErr', $arrErr); 
    5960$xoopsTpl->assign('arrStatus', $arrStatus); 
    6061$xoopsTpl->assign('arrCat', $arrCategory); 
     
    6263 
    6364include XOOPS_ROOT_PATH."/footer.php"; 
     65 
     66//--------------------------------------------------------------------------------------------------- 
     67 
     68function lfErrCheck($arrForm) { 
     69     
     70    $title_len = 50; 
     71    $body_len = 500; 
     72     
     73    $arrErr = array(); 
     74     
     75    if(empty($arrForm['title'])) { 
     76        $arrErr['title'] = " ¢¨ ¥¿¥¤¥È¥ë¤òÆþÎϤ·¤Æ²¼¤µ¤¤¡£"; 
     77    } else { 
     78        if(mb_strlen($arrForm['title']) > $title_len) $arrErr['title'] = " ¢¨ ¥¿¥¤¥È¥ë¤Ï$title_lenʸ»ú°ÊÆâ¤ÇÆþÎϤ·¤Æ²¼¤µ¤¤¡£"; 
     79    } 
     80 
     81    if(empty($arrForm['body'])) { 
     82        $arrErr['body'] = " ¢¨ ÆâÍÆ¤òÆþÎϤ·¤Æ²¼¤µ¤¤¡£"; 
     83    } else { 
     84        if(mb_strlen($arrForm['body']) > $title_len) $arrErr['title'] = " ¢¨ ÆâÍÆ¤Ï$body_lenʸ»ú°ÊÆâ¤ÇÆþÎϤ·¤Æ²¼¤µ¤¤¡£"; 
     85    } 
     86     
     87    return $arrErr; 
     88} 
     89 
    6490?> 
  • temp/test-xoops.ec-cube.net/html/modules/xoopspoll/templates/xoopspoll_new.html

    r776 r777  
    2323     
    2424    <table> 
    25         <{}> 
     25        <{section name=cnt loop=$arrErr}> 
    2626        <tr> 
    27             <td></td> 
     27            <td><{$arrErr[cnt]}></td> 
    2828        </tr> 
     29        <{/section}> 
    2930    </table> 
    3031     
Note: See TracChangeset for help on using the changeset viewer.