source: temp/test-xoops.ec-cube.net/html/modules/xoopspoll/pollrating.php @ 842

Revision 842, 4.4 KB checked in by uehara, 19 years ago (diff)
Line 
1<?php
2// $Id: pollresults.php,v 1.3 2005/09/04 20:46:12 onokazu Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27
28include "../../mainfile.php";
29include XOOPS_ROOT_PATH.'/class/pagenav.php';
30include XOOPS_ROOT_PATH."/modules/xoopspoll/include/constants.php";
31include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspoll.php";
32include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspolloption.php";
33include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspolllog.php";
34include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspollrenderer.php";
35
36$poll_id = $_GET['poll_id'];
37$option_id = $_GET['option_id'];
38if(empty($option_id)) $option_id = $_POST['option_id'];
39
40// ¥ª¥×¥·¥ç¥óID¤¬Èô¤ó¤Ç¤­¤Æ¤¤¤ë¤«¥Á¥§¥Ã¥¯
41$option_id = (!empty($option_id)) ? intval($option_id) : 0;
42if (empty($option_id)) {
43    redirect_header("pollresults.php?poll_id=".$poll_id,0);
44    exit();
45}
46$start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
47
48switch($_POST['mode']) {
49    case 'rating':
50        $poll_id = $_POST['poll_id'];
51        $arrErr = lfErrCheck($_POST);
52        if(count($arrErr) <= 0) {
53            $poll = new XoopsPoll($poll_id);
54            if ( $xoopsUser ) {
55                $uid = $xoopsUser->getVar("uid");
56            } else {
57                $uid = 0;
58            }
59            $poll->vote($option_id, xoops_getenv('REMOTE_ADDR'), $uid, $_POST['rating_id'], $_POST['comment']);
60            $poll->updateCount();
61            redirect_header(XOOPS_URL."/modules/xoopspoll/pollresults.php?poll_id=".$poll_id, 1, $msg);
62            exit();
63        }
64        break;
65    default:
66        break;
67}
68
69$xoopsOption['template_main'] = 'xoopspoll_rating.html';
70include XOOPS_ROOT_PATH."/header.php";
71
72$dummy = "";
73$renderer = new XoopsPollRenderer($dummy);
74
75$renderer->assignOption($xoopsTpl, $option_id);
76$count = $renderer->assignComment($xoopsTpl, $option_id, $start, POLL_COMMENT_VIEW);
77
78$nav = new XoopsPageNav($count, POLL_OPTION_VIEW, $start, "start", 'poll_id='.$poll_id.'&amp;option_id='.$option_id);
79$xoopsTpl->assign('forum_pagenav', $nav->renderNav(4));
80
81$xoopsTpl->assign('arrStatus', $arrStatus);
82$xoopsTpl->assign('arrCat', $arrCategory);
83$xoopsTpl->assign('arrRating', $arrRating);
84$xoopsTpl->assign('poll_id', $poll_id);
85$xoopsTpl->assign('start', $start);
86$xoopsTpl->assign('arrErr', $arrErr);
87
88include XOOPS_ROOT_PATH.'/include/comment_view.php';
89
90include XOOPS_ROOT_PATH."/footer.php";
91
92//---------------------------------------------------------------------------------------------------
93
94function lfErrCheck($arrForm) {
95   
96    $body_len = 200;
97   
98    $arrErr = array();
99   
100    if(mb_strlen($arrForm['comment']) > $title_len) {
101        $arrErr['title'] = " ¢¨ ¥³¥á¥ó¥È¤Ï".$body_len."ʸ»ú°ÊÆâ¤ÇÆþÎϤ·¤Æ²¼¤µ¤¤¡£";
102    }
103   
104    return $arrErr;
105}
106?>
Note: See TracBrowser for help on using the repository browser.