source: temp/test-xoops.ec-cube.net/html/modules/xoopspoll/admin/index.php @ 405

Revision 405, 22.5 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: index.php,v 1.4 2005/08/03 12:40:02 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//  ------------------------------------------------------------------------ //
27include '../../../include/cp_header.php';
28include XOOPS_ROOT_PATH."/modules/xoopspoll/include/constants.php";
29include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
30include_once XOOPS_ROOT_PATH."/class/xoopslists.php";
31include_once XOOPS_ROOT_PATH."/class/xoopsblock.php";
32include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspoll.php";
33include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspolloption.php";
34include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspolllog.php";
35include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspollrenderer.php";
36
37$op = "list";
38
39if (!empty($_GET['op'])) {
40    $op = $_GET['op'];
41} elseif (!empty($_POST['op'])) {
42    $op = $_POST['op'];
43}
44
45if ( $op == "list" ) {
46    $limit = (!empty($_GET['limit'])) ? $_GET['limit'] : 30;
47    $start = (!empty($_GET['start'])) ? $_GET['start'] : 0;
48    $polls_arr =& XoopsPoll::getAll(array(), true, "weight ASC, end_time DESC", $limit+1, $start);
49    xoops_cp_header();
50    echo "<h4>"._AM_POLLCONF."</h4>";
51    echo "<h4 style='text-align:left;'>"._AM_POLLSLIST."</h4>";
52    $polls_count = count($polls_arr);
53    if ( is_array($polls_arr) && $polls_count > 0) {
54        echo "<form action='index.php' method='post'><table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td class='bg2'>
55        <table width='100%' border='0' cellpadding='4' cellspacing='1'>
56        <tr class='bg3'><td>"._AM_DISPLAYBLOCK."</td><td>"._AM_DISPLAYORDER."</td><td>"._AM_POLLQUESTION."</td><td>"._AM_VOTERS."</td><td>"._AM_VOTES."</td><td>"._AM_EXPIRATION."</td><td>&nbsp;</td></tr>";
57        $max = ( $polls_count > $limit ) ? $limit : $polls_count;
58        for ( $i = 0; $i < $max; $i++ ) {
59            $checked = "";
60            if ( 1 == $polls_arr[$i]->getVar("display") ) {
61                $checked = " checked='checked'";
62            }
63            if ( $polls_arr[$i]->getVar("end_time") > time() ) {
64                $end = formatTimestamp($polls_arr[$i]->getVar("end_time"),"m");
65            } else {
66                $end = "<span style='color:#ff0000;'>"._AM_EXPIRED."</span><br /><a href='index.php?op=restart&amp;poll_id=".$polls_arr[$i]->getVar("poll_id")."'>"._AM_RESTART."</a>";
67            }
68            echo "<tr class='bg1'><td align='center'><input type='hidden' name='poll_id[$i]' value='".$polls_arr[$i]->getVar("poll_id")."' /><input type='hidden' name='old_display[$i]' value='".$polls_arr[$i]->getVar("display")."' /><input type='checkbox' name='display[$i]' value='1'".$checked." /></td><td><input type='hidden' name='old_weight[$i]' value='".$polls_arr[$i]->getVar("weight")."' /><input type='text' name='weight[$i]' value='".$polls_arr[$i]->getVar("weight")."' size='6' maxlength='5' /></td><td>".$polls_arr[$i]->getVar("question")."</td><td align='center'>".$polls_arr[$i]->getVar("voters")."</td><td align='center'>".$polls_arr[$i]->getVar("votes")."</td><td>".$end."</td><td align='right'><a href='index.php?op=edit&amp;poll_id=".$polls_arr[$i]->getVar("poll_id")."'>"._EDIT."</a><br /><a href='index.php?op=delete&amp;poll_id=".$polls_arr[$i]->getVar("poll_id")."'>"._DELETE."</a><br /><a href='index.php?op=log&amp;poll_id=".$polls_arr[$i]->getVar("poll_id")."'>"._AM_VIEWLOG."</a></td></tr>";
69        }
70        echo "<tr align='right' class='bg3'><td colspan='7'><input type='button' name='button' onclick=\"location='index.php?op=add'\" value='"._AM_ADDPOLL."' /> <input type='submit' value='"._SUBMIT."' /><input type='hidden' name='op' value='quickupdate' /></td></tr></table></td></tr></table></form>";
71        echo "<table width='100%'><tr><td align='left'>";
72        if ( $start > 0 ) {
73            $prev_start = ($start - $limit > 0) ? $start - $limit : 0;
74            echo "<a href='index.php?start=".$prev_start."&amp;limit=".$limit."'>"._PL_PREV."</a>";
75        } else {
76            echo "&nbsp;";
77        }
78        echo "</td><td align='right'>";
79        if ( $polls_count > $limit ) {
80            echo "<a href='index.php?start=".($start+$limit)."&amp;limit=".$limit."'>"._PL_NEXT."</a>";
81        }
82        echo "</td></tr></table>";
83    }
84    xoops_cp_footer();
85    exit();
86}
87
88if ( $op == "add" ) {
89    $poll_form = new XoopsThemeForm(_AM_CREATNEWPOLL, "poll_form", "index.php");
90    $question_text = new XoopsFormText(_AM_POLLQUESTION, "question", 50, 255);
91    $poll_form->addElement($question_text);
92    $desc_tarea = new XoopsFormTextarea(_AM_POLLDESC, "description");
93    $poll_form->addElement($desc_tarea);
94    $currenttime = formatTimestamp(time(), "Y-m-d H:i:s");
95    $endtime = formatTimestamp(time()+604800, "Y-m-d H:i:s");
96    $expire_text = new XoopsFormText(_AM_EXPIRATION."<br /><small>"._AM_FORMAT."<br />".sprintf(_AM_CURRENTTIME, $currenttime)."</small>", "end_time", 30, 19, $endtime);
97    $poll_form->addElement($expire_text);
98    $disp_yn = new XoopsFormRadioYN(_AM_DISPLAYBLOCK, "display", 1);
99    $poll_form->addElement($disp_yn);
100    $weight_text = new XoopsFormText(_AM_DISPLAYORDER, "weight", 6, 5, 0);
101    $poll_form->addElement($weight_text);
102    $multi_yn = new XoopsFormRadioYN(_AM_ALLOWMULTI, "multiple", 0);
103    $poll_form->addElement($multi_yn);
104    $notify_yn = new XoopsFormRadioYN(_AM_NOTIFY, "notify", 1);
105    $poll_form->addElement($notify_yn);
106    $option_tray = new XoopsFormElementTray(_AM_POLLOPTIONS, "");
107    $barcolor_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/modules/xoopspoll/images/colorbars/");
108    for($i = 0; $i < 10; $i++){
109        $current_bar = (current($barcolor_array) != "blank.gif") ? current($barcolor_array) : next($barcolor_array);
110        $option_text = new XoopsFormText("", "option_text[]", 50, 255);
111        $option_tray->addElement($option_text);
112        $color_select = new XoopsFormSelect("", "option_color[".$i."]", $current_bar);
113        $color_select->addOptionArray($barcolor_array);
114        $color_select->setExtra("onchange='showImgSelected(\"option_color_image[".$i."]\", \"option_color[".$i."]\", \"modules/xoopspoll/images/colorbars\", \"\", \"".XOOPS_URL."\")'");
115        $color_label = new XoopsFormLabel("", "<img src='".XOOPS_URL."/modules/xoopspoll/images/colorbars/".$current_bar."' name='option_color_image[".$i."]' id='option_color_image[".$i."]' width='30' align='bottom' height='15' alt='' /><br />");
116        $option_tray->addElement($color_select);
117        $option_tray->addElement($color_label);
118        if ( !next($barcolor_array) ) {
119            reset($barcolor_array);
120        }
121        unset($color_select, $color_label);
122    }
123    $poll_form->addElement($option_tray);
124    $submit_button = new XoopsFormButton("", "poll_submit", _SUBMIT, "submit");
125    $poll_form->addElement($submit_button);
126    $op_hidden = new XoopsFormHidden("op", "save");
127    $poll_form->addElement($op_hidden);
128    xoops_cp_header();
129    echo "<h4>"._AM_POLLCONF."</h4>";
130    $poll_form->display();
131    xoops_cp_footer();
132    exit();
133}
134
135if ( $op == "save" ) {
136    $poll = new XoopsPoll();
137    $poll->setVar("question", $_POST['question']);
138    $poll->setVar("description", $_POST['description']);
139    if ( !empty($_POST['end_time']) ) {
140        $poll->setVar("end_time", userTimeToServerTime(strtotime($_POST['end_time']), $xoopsUser->timezone()));
141    } else {
142        // if expiration date is not set, set it to 10 days from now
143        $poll->setVar("end_time", time() + (86400 * 10));
144    }
145    $poll->setVar("display", $_POST['display']);
146    $poll->setVar("weight", $_POST['weight']);
147    $poll->setVar("multiple", $_POST['multiple']);
148    if ( $_POST['notify'] == 1 ) {
149        // if notify, set mail status to "not mailed"
150        $poll->setVar("mail_status", POLL_NOTMAILED);
151    } else {
152        // if not notify, set mail status to already "mailed"
153        $poll->setVar("mail_status", POLL_MAILED);
154    }
155    $poll->setVar("user_id", $xoopsUser->getVar("uid"));
156    $new_poll_id = $poll->store();
157    if ( !empty($new_poll_id) ) {
158        $i = 0;
159        foreach ( $_POST['option_text'] as $optxt ) {
160            $optxt = trim($optxt);
161            if ( $optxt != "" ) {
162                $option = new XoopsPollOption();
163                $option->setVar("option_text", $optxt);
164                $option->setVar("option_color", $_POST['option_color'][$i]);
165                $option->setVar("poll_id", $new_poll_id);
166                $option->store();
167            }
168            $i++;
169        }
170        include_once XOOPS_ROOT_PATH.'/class/template.php';
171        xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
172    } else {
173        echo $poll->getHtmlErrors();
174        exit();
175    }
176    redirect_header("index.php",1,_AM_DBUPDATED);
177    exit();
178}
179
180if ( $op == "edit" ) {
181    $poll = new XoopsPoll($_GET['poll_id']);
182    $poll_form = new XoopsThemeForm(_AM_EDITPOLL, "poll_form", "index.php");
183    $author_label = new XoopsFormLabel(_AM_AUTHOR, "<a href='".XOOPS_URL."/userinfo.php?uid=".$poll->getVar("user_id")."'>".XoopsUser::getUnameFromId($poll->getVar("user_id"))."</a>");
184    $poll_form->addElement($author_label);
185    $question_text = new XoopsFormText(_AM_POLLQUESTION, "question", 50, 255, $poll->getVar("question", "E"));
186    $poll_form->addElement($question_text);
187    $desc_tarea = new XoopsFormTextarea(_AM_POLLDESC, "description", $poll->getVar("description", "E"));
188    $poll_form->addElement($desc_tarea);
189    $date = formatTimestamp($poll->getVar("end_time"), "Y-m-d H:i:s");
190    if ( !$poll->hasExpired() ) {
191        $expire_text = new XoopsFormText(_AM_EXPIRATION."<br /><small>"._AM_FORMAT."<br />".sprintf(_AM_CURRENTTIME, formatTimestamp(time(), "Y-m-d H:i:s"))."</small>", "end_time", 20, 19, $date);
192        $poll_form->addElement($expire_text);
193    } else {
194        $restart_label = new XoopsFormLabel(_AM_EXPIRATION, sprintf(_AM_EXPIREDAT, $date)."<br /><a href='index.php?op=restart&amp;poll_id=".$poll->getVar("poll_id")."'>"._AM_RESTART."</a>");
195        $poll_form->addElement($restart_label);
196    }
197    $disp_yn = new XoopsFormRadioYN(_AM_DISPLAYBLOCK, "display", $poll->getVar("display"));
198    $poll_form->addElement($disp_yn);
199    $weight_text = new XoopsFormText(_AM_DISPLAYORDER, "weight", 6, 5, $poll->getVar("weight"));
200    $poll_form->addElement($weight_text);
201    $multi_yn = new XoopsFormRadioYN(_AM_ALLOWMULTI, "multiple", $poll->getVar("multiple"));
202    $poll_form->addElement($multi_yn);
203    $options_arr =& XoopsPollOption::getAllByPollId($poll->getVar("poll_id"));
204    $notify_value = 1;
205    if ( $poll->getVar("mail_status") != 0 ) {
206        $notify_value = 0;
207    }
208    $notify_yn = new XoopsFormRadioYN(_AM_NOTIFY, "notify", $notify_value);
209    $poll_form->addElement($notify_yn);
210    $option_tray = new XoopsFormElementTray(_AM_POLLOPTIONS, "");
211    $barcolor_array =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/modules/xoopspoll/images/colorbars/");
212    $i = 0;
213    foreach($options_arr as $option){
214        $option_text = new XoopsFormText("", "option_text[]", 50, 255, $option->getVar("option_text"));
215        $option_tray->addElement($option_text);
216        $option_id_hidden = new XoopsFormHidden("option_id[]", $option->getVar("option_id"));
217        $option_tray->addElement($option_id_hidden);
218        $color_select = new XoopsFormSelect("", "option_color[".$i."]", $option->getVar("option_color"));
219        $color_select->addOptionArray($barcolor_array);
220        $color_select->setExtra("onchange='showImgSelected(\"option_color_image[".$i."]\", \"option_color[".$i."]\", \"modules/xoopspoll/images/colorbars\", \"\", \"".XOOPS_URL."\")'");
221        $color_label = new XoopsFormLabel("", "<img src='".XOOPS_URL."/modules/xoopspoll/images/colorbars/".$option->getVar("option_color", "E")."' name='option_color_image[".$i."]' id='option_color_image[".$i."]' width='30' align='bottom' height='15' alt='' /><br />");
222        $option_tray->addElement($color_select);
223        $option_tray->addElement($color_label);
224        unset($color_select, $color_label, $option_id_hidden, $option_text);
225        $i++;
226    }
227    $more_label = new XoopsFormLabel("", "<br /><a href='index.php?op=addmore&amp;poll_id=".$poll->getVar("poll_id")."'>"._AM_ADDMORE."</a>");
228    $option_tray->addElement($more_label);
229    $poll_form->addElement($option_tray);
230    $op_hidden = new XoopsFormHidden("op", "update");
231    $poll_form->addElement($op_hidden);
232    $poll_id_hidden = new XoopsFormHidden("poll_id", $poll->getVar("poll_id"));
233    $poll_form->addElement($poll_id_hidden);
234    $submit_button = new XoopsFormButton("", "poll_submit", _SUBMIT, "submit");
235    $poll_form->addElement($submit_button);
236    xoops_cp_header();
237    echo "<h4>"._AM_POLLCONF."</h4>";
238    $poll_form->display();
239    xoops_cp_footer();
240    exit();
241}
242
243if ( $op == "update" ) {
244    $poll = new XoopsPoll($_POST['poll_id']);
245    $poll->setVar("question", $_POST['question']);
246    $poll->setVar("description", $_POST['description']);
247    if ( !empty($_POST['end_time']) ) {
248        $end_time = userTimeToServerTime(strtotime($_POST['end_time']), $xoopsUser->timezone());
249        $poll->setVar("end_time", $end_time);
250    }
251    $poll->setVar("display", $_POST['display']);
252    $poll->setVar("weight", $_POST['weight']);
253    $poll->setVar("multiple", $_POST['multiple']);
254    if ( $_POST['notify'] == 1 && $end_time > time() ) {
255        // if notify, set mail status to "not mailed"
256        $poll->setVar("mail_status", POLL_NOTMAILED);
257    } else {
258        // if not notify, set mail status to already "mailed"
259        $poll->setVar("mail_status", POLL_MAILED);
260    }
261    if ( !$poll->store() ) {
262        echo $poll->getHtmlErrors();
263        exit();
264    }
265    $i = 0;
266    foreach ( $_POST['option_id'] as $opid ) {
267        $option = new XoopsPollOption($opid);
268        $option_text[$i] = trim ($_POST['option_text'][$i]);
269        if ( $option_text[$i] != "" ) {
270            $option->setVar("option_text", $option_text[$i]);
271            $option->setVar("option_color", $_POST['option_color'][$i]);
272            $option->store();
273        } else {
274            if ( $option->delete() != false ) {
275                XoopsPollLog::deleteByOptionId($option->getVar("option_id"));
276            }
277        }
278        $i++;
279    }
280    $poll->updateCount();
281    include_once XOOPS_ROOT_PATH.'/class/template.php';
282    xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
283    redirect_header("index.php",1,_AM_DBUPDATED);
284    exit();
285}
286
287if ( $op == "addmore" ) {
288    $poll = new XoopsPoll($_GET['poll_id']);
289    $poll_form = new XoopsThemeForm(_AM_ADDMORE, "poll_form", "index.php");
290    $question_label = new XoopsFormLabel(_AM_POLLQUESTION, $poll->getVar("question"));
291    $poll_form->addElement($question_label);
292    $option_tray = new XoopsFormElementTray(_AM_POLLOPTIONS, "");
293    $barcolor_array =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/modules/xoopspoll/images/colorbars/");
294    for($i = 0; $i < 10; $i++){
295        $current_bar = (current($barcolor_array) != "blank.gif") ? current($barcolor_array) : next($barcolor_array);
296        $option_text = new XoopsFormText("", "option_text[]", 50, 255);
297        $option_tray->addElement($option_text);
298        $color_select = new XoopsFormSelect("", "option_color[".$i."]", $current_bar);
299        $color_select->addOptionArray($barcolor_array);
300        $color_select->setExtra("onchange='showImgSelected(\"option_color_image[".$i."]\", \"option_color[".$i."]\", \"modules/xoopspoll/images/colorbars\", \"\", \"".XOOPS_URL."\")'");
301        $color_label = new XoopsFormLabel("", "<img src='".XOOPS_URL."/modules/xoopspoll/images/colorbars/".$current_bar."' name='option_color_image[".$i."]' id='option_color_image[".$i."]' width='30' align='bottom' height='15' alt='' /><br />");
302        $option_tray->addElement($color_select);
303        $option_tray->addElement($color_label);
304        unset($color_select, $color_label, $option_text);
305        if ( !next($barcolor_array) ) {
306            reset($barcolor_array);
307        }
308    }
309    $poll_form->addElement($option_tray);
310    $submit_button = new XoopsFormButton("", "poll_submit", _SUBMIT, "submit");
311    $poll_form->addElement($submit_button);
312    $op_hidden = new XoopsFormHidden("op", "savemore");
313    $poll_form->addElement($op_hidden);
314    $poll_id_hidden = new XoopsFormHidden("poll_id", $poll->getVar("poll_id"));
315    $poll_form->addElement($poll_id_hidden);
316    xoops_cp_header();
317    echo "<h4>"._AM_POLLCONF."</h4>";
318    $poll_form->display();
319    xoops_cp_footer();
320    exit();
321}
322
323if ( $op == "savemore" ) {
324    $poll = new XoopsPoll($_POST['poll_id']);
325    $i = 0;
326    foreach ( $_POST['option_text'] as $optxt ) {
327        $optxt = trim($optxt);
328        if ( $optxt != "" ) {
329            $option = new XoopsPollOption();
330            $option->setVar("option_text", $optxt);
331            $option->setVar("poll_id", $poll->getVar("poll_id"));
332            $option->setVar("option_color", $_POST['option_color'][$i]);
333            $option->store();
334        }
335        $i++;
336    }
337    include_once XOOPS_ROOT_PATH.'/class/template.php';
338    xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
339    redirect_header("index.php",1,_AM_DBUPDATED);
340    exit();
341}
342
343if ( $op == "delete" ) {
344    xoops_cp_header();
345    echo "<h4>"._AM_POLLCONF."</h4>";
346    $poll = new XoopsPoll($_GET['poll_id']);
347    xoops_confirm(array('op' => 'delete_ok', 'poll_id' => $poll->getVar('poll_id')), 'index.php', sprintf(_AM_RUSUREDEL,$poll->getVar("question")));
348    xoops_cp_footer();
349    exit();
350}
351
352if ( $op == "delete_ok" ) {
353    $poll = new XoopsPoll($_POST['poll_id']);
354    if ( $poll->delete() != false ) {
355        XoopsPollOption::deleteByPollId($poll->getVar("poll_id"));
356        XoopsPollLog::deleteByPollId($poll->getVar("poll_id"));
357        include_once XOOPS_ROOT_PATH.'/class/template.php';
358        xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
359        // delete comments for this poll
360        xoops_comment_delete($xoopsModule->getVar('mid'), $poll->getVar('poll_id'));
361
362    }
363    redirect_header("index.php",1,_AM_DBUPDATED);
364    exit();
365}
366
367if ( $op == "restart" ) {
368    $poll = new XoopsPoll($_GET['poll_id']);
369    $poll_form = new XoopsThemeForm(_AM_RESTARTPOLL, "poll_form", "index.php");
370    $expire_text = new XoopsFormText(_AM_EXPIRATION."<br /><small>"._AM_FORMAT."<br />".sprintf(_AM_CURRENTTIME, formatTimestamp(time(), "Y-m-d H:i:s"))."</small>", "end_time", 20, 19, formatTimestamp(time()+604800, "Y-m-d H:i:s"));
371    $poll_form->addElement($expire_text);
372    $notify_yn = new XoopsFormRadioYN(_AM_NOTIFY, "notify", 1);
373    $poll_form->addElement($notify_yn);
374    $reset_yn = new XoopsFormRadioYN(_AM_RESET, "reset", 0);
375    $poll_form->addElement($reset_yn);
376    $op_hidden = new XoopsFormHidden("op", "restart_ok");
377    $poll_form->addElement($op_hidden);
378    $poll_id_hidden = new XoopsFormHidden("poll_id", $poll->getVar("poll_id"));
379    $poll_form->addElement($poll_id_hidden);
380    $submit_button = new XoopsFormButton("", "poll_submit", _AM_RESTART, "submit");
381    $poll_form->addElement($submit_button);
382    xoops_cp_header();
383    echo "<h4>"._AM_POLLCONF."</h4>";
384    $poll_form->display();
385    xoops_cp_footer();
386    exit();
387}
388
389if ( $op == "restart_ok" ) {
390    $poll = new XoopsPoll($_POST['poll_id']);
391    if ( !empty($_POST['end_time']) ) {
392        $end_time = userTimeToServerTime(strtotime($_POST['end_time']), $xoopsUser->timezone());
393        $poll->setVar("end_time", $end_time);
394    } else {
395        $poll->setVar("end_time", time() + (86400 * 10));
396    }
397    if ( $_POST['notify'] == 1 && $end_time > time() ) {
398        // if notify, set mail status to "not mailed"
399        $poll->setVar("mail_status", POLL_NOTMAILED);
400    } else {
401        // if not notify, set mail status to already "mailed"
402        $poll->setVar("mail_status", POLL_MAILED);
403    }
404    if ( $_POST['reset'] == 1 ) {
405        // reset all logs
406        XoopsPollLog::deleteByPollId($poll->getVar("poll_id"));
407        XoopsPollOption::resetCountByPollId($poll->getVar("poll_id"));
408    }
409    if (!$poll->store()) {
410        echo $poll->getHtmlErrors();
411        exit();
412    }
413    $poll->updateCount();
414    include_once XOOPS_ROOT_PATH.'/class/template.php';
415    xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
416    redirect_header("index.php",1,_AM_DBUPDATED);
417    exit();
418}
419
420if ( $op == "log" ) {
421    xoops_cp_header();
422    echo "<h4>"._AM_POLLCONF."</h4>";
423    echo "<br />View Log<br /> Sorry, not yet. ;-)";
424    xoops_cp_footer();
425    exit();
426}
427
428if ( $op == "quickupdate" ) {
429    $count = count($_POST['poll_id']);
430    for ( $i = 0; $i < $count; $i++ ) {
431        $display[$i] = empty($_POST['display'][$i]) ? 0 : 1;
432        $weight[$i] = empty($_POST['weight'][$i]) ? 0 : intval($_POST['weight'][$i]);
433        if ( $display[$i] != $_POST['old_display'][$i] || $weight[$i] != $_POST['old_weight'][$i] ) {
434            $poll = new XoopsPoll($_POST['poll_id'][$i]);
435            $poll->setVar("display", $display[$i]);
436            $poll->setVar("weight", $weight[$i]);
437            $poll->store();
438        }
439    }
440    include_once XOOPS_ROOT_PATH.'/class/template.php';
441    xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
442    redirect_header("index.php",1,_AM_DBUPDATED);
443    exit();
444}
445?>
Note: See TracBrowser for help on using the repository browser.