diff --git a/class/poll.php b/class/poll.php index 0291ce3..642e795 100644 --- a/class/poll.php +++ b/class/poll.php @@ -458,38 +458,51 @@ class Poll * @param string $text * @param string $title */ - function pollCommentShow($tpl_dir, $lang_file, $pid, $theme, $errors='', $text='', $title='') - { - global $AVE_DB, $AVE_Template; +function pollCommentShow($tpl_dir, $lang_file, $pid, $theme, $errors='', $text='', $title='') +{ + global $AVE_DB, $AVE_Template; - $AVE_Template->config_load($lang_file, 'displayform'); + $AVE_Template->config_load($lang_file, 'displayform'); + $pid = (int)$pid; - $row = $AVE_DB->Query(" - SELECT * - FROM " . PREFIX . "_module_poll - WHERE id = '" . $pid . "' - LIMIT 1 - ")->FetchRow(); - $groups = explode(',', $row->poll_groups_id); + $row = $AVE_DB->Query(" + SELECT * + FROM " . PREFIX . "_module_poll + WHERE id = '" . $pid . "' + LIMIT 1 + ")->FetchRow(); - if ($row->poll_status == 1 && $row->poll_can_comment == 1 && in_array(UGROUP, $groups)) - { - $AVE_Template->assign('cancomment', 1); - } - $AVE_Template->assign('max_chars', $this->_commentwords); + if (!$row) { + $row = new stdClass(); + $row->poll_groups_id = ''; + $row->poll_status = 0; + $row->poll_can_comment = 0; + $row->poll_anti_spam = 0; + if (empty($errors)) $errors = "Опрос с ID {$pid} не найден"; + } - if (isset($row->poll_anti_spam) && $row->poll_anti_spam == 1 && function_exists('imagettftext') && function_exists('imagejpeg')) - { - $AVE_Template->assign('anti_spam', 1); - } + $groups = explode(',', $row->poll_groups_id ?? ''); - if (!empty($errors)) $AVE_Template->assign('errors', $errors); + if ($row->poll_status == 1 && $row->poll_can_comment == 1 && in_array(UGROUP, $groups)) + { + $AVE_Template->assign('cancomment', 1); + } + + $AVE_Template->assign('max_chars', $this->_commentwords); - $AVE_Template->assign('theme_folder', $theme); - $AVE_Template->assign('title', $title); - $AVE_Template->assign('text', $text); - $AVE_Template->display($tpl_dir . 'poll_form.tpl'); - } + if (isset($row->poll_anti_spam) && $row->poll_anti_spam == 1 && function_exists('imagettftext') && function_exists('imagejpeg')) + { + $AVE_Template->assign('anti_spam', 1); + } + + if (!empty($errors)) $AVE_Template->assign('errors', $errors); + + $AVE_Template->assign('theme_folder', $theme); + $AVE_Template->assign('title', $title); + $AVE_Template->assign('text', $text); + + $AVE_Template->display($tpl_dir . 'poll_form.tpl'); +} /** * Метод создания нового комментария (UTF-8 Only) diff --git a/templates/poll_form.tpl b/templates/poll_form.tpl index 046faac..61a73a3 100644 --- a/templates/poll_form.tpl +++ b/templates/poll_form.tpl @@ -1,93 +1,82 @@ - - -
- -