1<?php
2/**
3 * XOOPS comment form
4 *
5 * You may not change or alter any portion of this comment or credits
6 * of supporting developers from this source code or any supporting source code
7 * which is considered copyrighted (c) material of the original comment or credit authors.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
13 * @license             GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
14 * @package             kernel
15 * @since               2.0.0
16 * @author              Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
17 */
18
19if (!defined('XOOPS_ROOT_PATH') || !is_object($xoopsModule)) {
20    die('Restricted access');
21}
22
23$com_modid = $xoopsModule->getVar('mid');
24
25xoops_load('XoopsLists');
26xoops_load('XoopsFormLoader');
27
28$cform = new XoopsThemeForm(_CM_POSTCOMMENT, 'commentform', 'comment_post.php', 'post', true);
29if (isset($xoopsModuleConfig['com_rule'])) {
30    include_once $GLOBALS['xoops']->path('include/comment_constants.php');
31    switch ($xoopsModuleConfig['com_rule']) {
32        case XOOPS_COMMENT_APPROVEALL:
33            $rule_text = _CM_COMAPPROVEALL;
34            break;
35        case XOOPS_COMMENT_APPROVEUSER:
36            $rule_text = _CM_COMAPPROVEUSER;
37            break;
38        case XOOPS_COMMENT_APPROVEADMIN:
39        default:
40            $rule_text = _CM_COMAPPROVEADMIN;
41            break;
42    }
43    $cform->addElement(new XoopsFormLabel(_CM_COMRULES, $rule_text));
44}
45
46$cform->addElement(new XoopsFormText(_CM_TITLE, 'com_title', 50, 255, $com_title), true);
47// Start add by voltan
48if (!($com_user == '' && $com_email == '') || !$xoopsUser) {
49    $cform->addElement(new XoopsFormText(_CM_USER, 'com_user', 50, 60, $com_user), true);
50    $cform->addElement(new XoopsFormText(_CM_EMAIL, 'com_email', 50, 60, $com_email), true);
51    $cform->addElement(new XoopsFormText(_CM_URL, 'com_url', 50, 60, $com_url), false);
52}
53// End add by voltan
54$icons_radio   = new XoopsFormRadio(_MESSAGEICON, 'com_icon', $com_icon);
55$subject_icons = XoopsLists::getSubjectsList();
56foreach ($subject_icons as $iconfile) {
57    $icons_radio->addOption($iconfile, '<img src="' . XOOPS_URL . '/images/subject/' . $iconfile . '" alt="" />');
58}
59$cform->addElement($icons_radio);
60// editor
61$editor = xoops_getModuleOption('comments_editor', 'system');
62if (class_exists('XoopsFormEditor')) {
63    $configs = array(
64        'name'   => 'com_text',
65        'value'  => $com_text,
66        'rows'   => 25,
67        'cols'   => 90,
68        'width'  => '100%',
69        'height' => '400px',
70        'editor' => $editor);
71    $cform->addElement(new XoopsFormEditor(_CM_MESSAGE, 'com_text', $configs, false, $onfailure = 'textarea'));
72} else {
73    $cform->addElement(new XoopsFormDhtmlTextArea(_CM_MESSAGE, 'com_text', $com_text, 10, 50), true);
74}
75$option_tray = new XoopsFormElementTray(_OPTIONS, '<br>');
76$button_tray = new XoopsFormElementTray('', '&nbsp;');
77
78if (is_object($xoopsUser)) {
79    /* @var  XoopsUser $xoopsUser */
80    if (isset($xoopsModuleConfig['com_anonpost'])) {
81        if ($xoopsModuleConfig['com_anonpost'] == 1) {
82            $noname          = !empty($noname) ? 1 : 0;
83            $noname_checkbox = new XoopsFormCheckBox('', 'noname', $noname);
84            $noname_checkbox->addOption(1, _POSTANON);
85            $option_tray->addElement($noname_checkbox);
86        }
87    }
88    if (false !== $xoopsUser->isAdmin($com_modid)) {
89        // show status change box when editing (comment id is not empty)
90        if (!empty($com_id)) {
91            include_once $GLOBALS['xoops']->path('include/comment_constants.php');
92            $status_select = new XoopsFormSelect(_CM_STATUS, 'com_status', $com_status);
93            $status_select->addOptionArray(array(
94                                               XOOPS_COMMENT_PENDING => _CM_PENDING,
95                                               XOOPS_COMMENT_ACTIVE  => _CM_ACTIVE,
96                                               XOOPS_COMMENT_HIDDEN  => _CM_HIDDEN));
97            $cform->addElement($status_select);
98            $button_tray->addElement(new XoopsFormButton('', 'com_dodelete', _DELETE, 'submit'));
99        }
100        if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
101            $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $dohtml);
102            $html_checkbox->addOption(1, _CM_DOHTML);
103            $option_tray->addElement($html_checkbox);
104        }
105    }
106}
107if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
108}
109$smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $dosmiley);
110$smiley_checkbox->addOption(1, _CM_DOSMILEY);
111$option_tray->addElement($smiley_checkbox);
112$xcode_checkbox = new XoopsFormCheckBox('', 'doxcode', $doxcode);
113$xcode_checkbox->addOption(1, _CM_DOXCODE);
114$option_tray->addElement($xcode_checkbox);
115if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) {
116    $br_checkbox = new XoopsFormCheckBox('', 'dobr', $dobr);
117    $br_checkbox->addOption(1, _CM_DOAUTOWRAP);
118    $option_tray->addElement($br_checkbox);
119} else {
120    $cform->addElement(new xoopsFormHidden('dohtml', 1));
121    $cform->addElement(new xoopsFormHidden('dobr', 0));
122}
123$cform->addElement($option_tray);
124if (!$xoopsUser) {
125    $cform->addElement(new XoopsFormCaptcha());
126}
127$cform->addElement(new XoopsFormHidden('com_pid', (int)$com_pid));
128$cform->addElement(new XoopsFormHidden('com_rootid', (int)$com_rootid));
129$cform->addElement(new XoopsFormHidden('com_id', $com_id));
130$cform->addElement(new XoopsFormHidden('com_itemid', $com_itemid));
131$cform->addElement(new XoopsFormHidden('com_order', $com_order));
132$cform->addElement(new XoopsFormHidden('com_mode', $com_mode));
133
134// add module specific extra params
135if ('system' !== $xoopsModule->getVar('dirname')) {
136    $comment_config = $xoopsModule->getInfo('comments');
137    if (isset($comment_config['extraParams']) && is_array($comment_config['extraParams'])) {
138        $myts = MyTextSanitizer::getInstance();
139        foreach ($comment_config['extraParams'] as $extra_param) {
140            // This routine is included from forms accessed via both GET and POST
141            $hidden_value = '';
142            if (isset($_POST[$extra_param])) {
143                $hidden_value = $myts->stripSlashesGPC($_POST[$extra_param]);
144            } elseif (isset($_GET[$extra_param])) {
145                $hidden_value = $myts->stripSlashesGPC($_GET[$extra_param]);
146            }
147            $cform->addElement(new XoopsFormHidden($extra_param, $hidden_value));
148        }
149    }
150}
151$button_tray->addElement(new XoopsFormButton('', 'com_dopreview', _PREVIEW, 'submit'));
152$button_tray->addElement(new XoopsFormButton('', 'com_dopost', _CM_POSTCOMMENT, 'submit'));
153$cform->addElement($button_tray);
154$cform->display();
155