| Plugin hackpoll |
| Wiki - Kunena JoniJnm Edition |
| Escrito por Jónatan Núñez |
Cambios
DescripciónPlugin de xillibit para poder insertar encuestas en Kunena. Modificación
Busca Mostrar/Ocultar código html4strict <tr>
<td id="fb_post_buttons" colspan = "2" style = "text-align: center;">
<input type="submit" name="submit" class="fb_button" value="<?php @print(' '._GEN_CONTINUE.' ');?>" onclick="return submitForm()" onmouseover = "javascript:jQuery('input[name=helpbox]').val('<?php @print(_KUNENA_EDITOR_HELPLINE_SUBMIT);?>')" />
<input type="button" name="preview" class="fb_button" value="<?php @print(' '._PREVIEW.' ');?>" onClick="fbGetPreview(document.postform.message.value,<?php echo KUNENA_COMPONENT_ITEMID?>);" onmouseover = "javascript:jQuery('input[name=helpbox]').val('<?php @print(_KUNENA_EDITOR_HELPLINE_PREVIEW);?>')" />
<input type="button" name="cancel" class="fb_button" value="<?php @print(' '._GEN_CANCEL.' ');?>" onclick="javascript:window.history.back();" onmouseover = "javascript:jQuery('input[name=helpbox]').val('<?php @print(_KUNENA_EDITOR_HELPLINE_CANCEL);?>')" />
</td>
</tr>Añade después
Busca Mostrar/Ocultar código html4strict Añade arriba
Busca Añade arriba //******************************************************************************
$polltitle = JRequest::getVar('poll_title' , 0);
$optionsnumbers = JRequest::getInt('number_total_options' , '');
if(!empty($optionsnumbers) && !empty($polltitle))
{
$poll_exist = "1";
//Begin Poll management options
for($ioptions = 1; $ioptions <= $optionsnumbers; $ioptions++){
$optionvalue[$ioptions] = addslashes(JRequest::getVar('field_option'.$ioptions , null));
}
$polltitle = addslashes($polltitle);
}
else
{
$poll_exist = "0";
}
//******************************************************************************Cambia if (!isset($pid))
{
$kunena_db->setQuery("INSERT INTO #__fb_messages
(parent,thread,catid,name,userid,email,subject,time,ip,topic_emoticon,hold)
VALUES('$parent','$thread','$catid','$fb_authorname','{$kunena_my->id}','$email','$subject','$posttime','$ip','$topic_emoticon','$holdPost')");
if ($kunena_db->query())
{
$pid = $kunena_db->insertId();Por if (!isset($pid))
{
//Query modified for hack poll
if (JoniJnm_API::plugin_exists("hackpoll")) {
//Query modified for hack poll
$kunena_db->setQuery("INSERT INTO #__fb_messages
(parent,thread,catid,name,userid,email,subject,time,ip,topic_emoticon,hold,poll_exist)
VALUES('$parent','$thread','$catid','$fb_authorname','{$kunena_my->id}','$email','$subject','$posttime','$ip','$topic_emoticon','$holdPost','$poll_exist')");
}
else {
$kunena_db->setQuery("INSERT INTO #__fb_messages
(parent,thread,catid,name,userid,email,subject,time,ip,topic_emoticon,hold)
VALUES('$parent','$thread','$catid','$fb_authorname','{$kunena_my->id}','$email','$subject','$posttime','$ip','$topic_emoticon','$holdPost')");
}
//*******************************************
if ($kunena_db->query())
{
$pid = $kunena_db->insertId();
//Insert in the database the informations for the poll and the options for the poll
if(!empty($polltitle) && !empty($optionsnumbers)){
$kunena_db->setQuery("INSERT INTO #__fb_polls
(title,topicid,options)
VALUES('$polltitle','$pid','$optionsnumbers')");
$kunena_db->query() or trigger_dberror('Impossible to insert the element in the table fb_polls.');
for($i = 1; $i <= sizeof($optionvalue); $i++){
$kunena_db->setQuery("INSERT INTO #__fb_polls_datas
(text,pollid)
VALUES('$optionvalue[$i]','$pid')");
$kunena_db->query() or trigger_dberror('Impossible to insert the element in the table fb_polls_datas.');
}
}
//******************************************************************************Busca else if ($do == "edit")
{
$allowEdit = 0;
$id = (int)$id;
$kunena_db->setQuery("SELECT * FROM #__fb_messages AS m LEFT JOIN #__fb_messages_text AS t ON m.id=t.mesid WHERE m.id='{$id}'");
$message1 = $kunena_db->loadObjectList();
check_dberror("Unable to load message.");
$mes = $message1[0];
$userID = $mes->userid;Añade después //save the options for query after and load the text options, the number options is for create the fields in the form after
if($message1[0]->poll_exist == "1") {
$kunena_db->setQuery("SELECT * FROM #__fb_polls_datas AS a INNER JOIN #__fb_polls AS b ON a.pollid=b.topicid WHERE a.pollid=$id");
$polldatasedit = $kunena_db->loadObjectList();
$nbpolloptions = $polldatasedit[0]->options;
}Busca if (count($message1) > 0)
{
// Re-check the hold. If post gets edited and review is set to ON for this category
// check if the post must be reviewed by a Moderator prior to showing
// doesn't apply to admin/moderator posts ;-)
$holdPost = 0;
if (!$is_Moderator)
{
$kunena_db->setQuery("SELECT review FROM #__fb_categories WHERE id='{$catid}'");
$kunena_db->query() or trigger_dberror('Unable to load review flag from categories.');
$holdPost = $kunena_db->loadResult();
}Añade después //Start Hack poll by xillibit
//**************************************************
//update the poll when an user edit his post
if(!empty($polltitle) && !empty($optionsnumbers)){
$kunena_db->setQuery("SELECT options FROM #__fb_polls WHERE topicid=$id");
$datas = $kunena_db->loadObjectList();
$kunena_db->setQuery("SELECT id FROM #__fb_polls_datas WHERE pollid={$id}");
$infospollsdatas2 = $kunena_db->loadObjectList();
if($datas[0]->options == $optionsnumbers){
$kunena_db->setQuery("UPDATE #__fb_messages SET poll_exist=1 WHERE id=$id");
$kunena_db->query();
$kunena_db->setQuery("UPDATE #__fb_polls SET title='{$polltitle}' WHERE topicid={$id}");
$kunena_db->query();
$j = "0";
for($i=1; $i <= sizeof($optionvalue);$i++) {
$kunena_db->setQuery("UPDATE #__fb_polls_datas SET text='{$optionvalue[$i]}' WHERE id={$infospollsdatas2[$j]->id}");
$kunena_db->query();
$j++;
}
}
else {
$kunena_db->setQuery("UPDATE #__fb_polls SET title='{$polltitle}', options='{$optionsnumbers}' WHERE topicid={$id}");
$kunena_db->query();
for($i=0; $i < $datas[0]->options;$i++) {
$kunena_db->setQuery("DELETE FROM #__fb_polls_datas WHERE id={$infospollsdatas2[$i]->id}");
$kunena_db->query();
}
for($i = 1; $i <= $optionsnumbers; $i++){
$kunena_db->setQuery("INSERT INTO #__fb_polls_datas (text,pollid) VALUES('$optionvalue[$i]','$id')");
$kunena_db->query();
}
}
}
//**************************************************************************
//En of hack poll by xillibitArchivos nuevosDescarga el plugin hackpoll, descomprimelo y súbelo a components/com_kunena/JoniJnm_Plugins
|



