diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 499e48f..bb714a9 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,5 +1,7 @@ # language: php build: + environment: + php: 8.0.11 nodes: tests: true analysis: @@ -14,9 +16,9 @@ build: override: true tests: override: - - php-scrutinizer-run --enable-security-analysis + - php-scrutinizer-run --enable-security-analysis filter: dependency_paths: - - XoopsCore25/* - - tag/* - - newbb/* + - XoopsCore25/* + - tag/* + - newbb/* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 901524b..8af467f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,15 @@ -![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png) +![alt XOOPS CMS](https://xoops.org/images/logoXoopsPhp81.png) # Contributing to [XOOPS CMS](https://xoops.org) [![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org) [![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html) Contributions are **welcome** and will be fully **credited**. -We accept contributions via Pull Requests on [Github](https://github.com/XoopsModules25x/xoopspoll). +We accept contributions via Pull Requests on [GitHub](https://github.com/XoopsModules25x/xoopspoll). ## Pull Requests -- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). +- **[PSR-12 Coding Standard](https://www.php-fig.org/psr/psr-12/)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). - **Add tests!** - We encourage providing tests for your contributions. - **Document any change in behavior** - Make sure the `/docs/changelog.txt` and any other relevant documentation are up-to-date. - **Consider our release cycle** - We try to follow [Semantic Versioning v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. @@ -17,4 +17,4 @@ We accept contributions via Pull Requests on [Github](https://github.com/XoopsMo - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. -**Happy coding, and _May the Source be with You_!** +Happy coding, and **_May the Source be with You_**! diff --git a/README.md b/README.md index 039cff3..66a7dd2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![alt XOOPS CMS](https://xoops.org/images/logoXoops4GithubRepository.png) +![alt XOOPS CMS](https://xoops.org/images/logoXoopsPhp81.png) ## XoopsPoll module for [XOOPS CMS 2.5.9+](https://xoops.org) [![XOOPS CMS Module](https://img.shields.io/badge/XOOPS%20CMS-Module-blue.svg)](https://xoops.org) @@ -7,8 +7,7 @@ [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/mambax7/xoopspoll.svg?style=flat)](https://scrutinizer-ci.com/g/XoopsModules25x/xoopspoll/?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/grade/85a08057185d440e9ca996303d3e3c26)](https://www.codacy.com/app/mambax7/xoopspoll_2) [![Code Climate](https://img.shields.io/codeclimate/github/mambax7/xoopspoll.svg?style=flat)](https://codeclimate.com/github/XoopsModules25x/xoopspoll) -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/62de8735-2c10-41b8-9faa-d4cfac041975/mini.png)](https://insight.sensiolabs.com/projects/62de8735-2c10-41b8-9faa-d4cfac041975) -[![Latest Pre-Resease](https://img.shields.io/github/tag/XoopsModules25x/xoopspoll.svg?style=flat)](https://github.com/XoopsModules25x/xoopspoll/tags/) +[![Latest Pre-Release](https://img.shields.io/github/tag/XoopsModules25x/xoopspoll.svg?style=flat)](https://github.com/XoopsModules25x/xoopspoll/tags/) [![Latest Version](https://img.shields.io/github/release/XoopsModules25x/xoopspoll.svg?style=flat)](https://github.com/XoopsModules25x/xoopspoll/releases/) **XoopsPolls** module for [XOOPS CMS](https://xoops.org) can be used to display interactive survey forms on your site. Each poll can display a question on which visitors can ‘vote’. diff --git a/admin/about.php b/admin/about.php index d9c56c3..d1f2fa5 100644 --- a/admin/about.php +++ b/admin/about.php @@ -1,4 +1,4 @@ -displayNavigation(basename(__FILE__)); -$adminObject::setPaypal('xoopsfoundation@gmail.com'); +Admin::setPaypal('xoopsfoundation@gmail.com'); $adminObject->displayAbout(false); require_once __DIR__ . '/admin_footer.php'; diff --git a/admin/admin_footer.php b/admin/admin_footer.php index 8760e65..e5959dc 100644 --- a/admin/admin_footer.php +++ b/admin/admin_footer.php @@ -1,4 +1,4 @@ -\n" - . "
\n" - . " XOOPS\n" - . "
\n" - . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" - . ''; +echo "
\n" . "
\n" . " XOOPS\n" . "
\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . '
'; xoops_cp_footer(); - diff --git a/admin/admin_header.php b/admin/admin_header.php index affced4..57c6ab6 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -1,4 +1,4 @@ -getModule()->getInfo('modicons32'); // Load language files @@ -57,6 +55,7 @@ $helper->loadLanguage('modinfo'); $helper->loadLanguage('main'); $helper->loadLanguage('common'); +$helper->loadLanguage('blocksadmin'); $myts = \MyTextSanitizer::getInstance(); diff --git a/admin/blockform.php b/admin/blockform.php deleted file mode 100644 index 7ba660a..0000000 --- a/admin/blockform.php +++ /dev/null @@ -1,129 +0,0 @@ -loadLanguage('blocksadmin'); - -$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true); -if (isset($block['name'])) { - $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_NAME, $block['name'])); -} -$side_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']); -$side_select->addOptionArray([ - 0 => _AM_SYSTEM_BLOCKS_SBLEFT, - 1 => _AM_SYSTEM_BLOCKS_SBRIGHT, - 3 => _AM_SYSTEM_BLOCKS_CBLEFT, - 4 => _AM_SYSTEM_BLOCKS_CBRIGHT, - 5 => _AM_SYSTEM_BLOCKS_CBCENTER, - 7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT, - 8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT, - 9 => _AM_SYSTEM_BLOCKS_CBBOTTOM, - ]); -$form->addElement($side_select); -$form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight'])); -$form->addElement(new \XoopsFormRadioYN(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible'])); -$mod_select = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true); -/** @var XoopsModuleHandler $moduleHandler */ -$moduleHandler = xoops_getHandler('module'); -$criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); -$criteria->add(new \Criteria('isactive', 1)); -$module_list = $moduleHandler->getList($criteria); -$module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; -$module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; -ksort($module_list); -$mod_select->addOptionArray($module_list); -$form->addElement($mod_select); -$form->addElement(new \XoopsFormText(_AM_TITLE, 'btitle', 50, 255, $block['title']), false); -if ($block['is_custom']) { - $textarea = new \XoopsFormDhtmlTextArea(_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70); - $textarea->setDescription('' . _AM_SYSTEM_BLOCKS_USEFULTAGS . '
' . sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . ''); - $form->addElement($textarea, true); - $ctype_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']); - $ctype_select->addOptionArray([ - 'H' => _AM_SYSTEM_BLOCKS_HTML, - 'P' => _AM_SYSTEM_BLOCKS_PHP, - 'S' => _AM_SYSTEM_BLOCKS_AFWSMILE, - 'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE, - ]); - $form->addElement($ctype_select); -} else { - if ('' !== $block['template']) { - /** @var XoopsTplfileHandler $tplfileHandler */ - $tplfileHandler = xoops_getHandler('tplfile'); - /** @var \XoopsTplfile[] $btemplate */ - $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); - if (count($btemplate) > 0) { - $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '' . _AM_SYSTEM_BLOCKS_EDITTPL . '')); - } else { - $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']); - if (count($btemplate2) > 0) { - $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '' . _AM_SYSTEM_BLOCKS_EDITTPL . '')); - } - } - } - if (false !== $block['edit_form']) { - $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form'])); - } -} -$cache_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']); -$cache_select->addOptionArray([ - '0' => _NOCACHE, - '30' => sprintf(_SECONDS, 30), - '60' => _MINUTE, - '300' => sprintf(_MINUTES, 5), - '1800' => sprintf(_MINUTES, 30), - '3600' => _HOUR, - '18000' => sprintf(_HOURS, 5), - '86400' => _DAY, - '259200' => sprintf(_DAYS, 3), - '604800' => _WEEK, - '2592000' => _MONTH, - ]); -$form->addElement($cache_select); - -/** @var \XoopsGroupPermHandler $grouppermHandler */ -$grouppermHandler = xoops_getHandler('groupperm'); -$groups = $grouppermHandler->getGroupIds('block_read', $block['bid']); - -$form->addElement(new \XoopsFormSelectGroup(_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true)); - -if (isset($block['bid'])) { - $form->addElement(new \XoopsFormHidden('bid', $block['bid'])); -} -$form->addElement(new \XoopsFormHidden('op', $block['op'])); -$form->addElement(new \XoopsFormHidden('fct', 'blocksadmin')); -$button_tray = new \XoopsFormElementTray('', ' '); -if ($block['is_custom']) { - $button_tray->addElement(new \XoopsFormButton('', 'previewblock', _PREVIEW, 'submit')); -} - -//Submit buttons -$button_tray = new \XoopsFormElementTray('', ''); -$submit_button = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit'); -$button_tray->addElement($submit_button); - -$cancel_button = new \XoopsFormButton('', '', _CANCEL, 'button'); -$cancel_button->setExtra('onclick="history.go(-1)"'); -$button_tray->addElement($cancel_button); - -$form->addElement($button_tray); diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index 4776c80..bc8ae70 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -1,591 +1,60 @@ -getDirname(); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); -/** @var Helper $helper */ -$helper = Helper::getInstance(); - -$helper->loadLanguage('blocksadmin'); +$xoopsModule = XoopsModule::getByDirname($moduleDirName); if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule) || !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403')); } -if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { - require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; - $op = 'list'; - if (isset($_POST)) { - foreach ($_POST as $k => $v) { - ${$k} = $v; - } - } - /* - if (Request::hasVar('op', 'GET')) { - if ('edit' === $_GET['op'] || 'delete' === $_GET['op'] || 'delete_ok' === $_GET['op'] || 'clone' === $_GET['op'] - || 'edit' === $_GET['op']) { - $op = $_GET['op']; - $bid = Request::getInt('bid', 0, 'GET'); - } - */ - - $op = Request::getString('op', $op); - if (in_array($op, ['edit', 'delete', 'delete_ok', 'clone'])) { - $bid = Request::getInt('bid', 0, 'GET'); - } - - function listBlocks() - { - global $xoopsModule, $pathIcon16; - require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - xoops_loadLanguage('admin', 'system'); - xoops_loadLanguage('admin/blocksadmin', 'system'); - xoops_loadLanguage('admin/groups', 'system'); - - /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - /** @var \XoopsMemberHandler $memberHandler */ - $memberHandler = xoops_getHandler('member'); - /** @var \XoopsGroupPermHandler $grouppermHandler */ - $grouppermHandler = xoops_getHandler('groupperm'); - $groups = $memberHandler->getGroups(); - $criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); - $criteria->add(new \Criteria('isactive', 1)); - $module_list = $moduleHandler->getList($criteria); - $module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; - $module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; - ksort($module_list); - echo " -

" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '

'; - $moduleHandler = xoops_getHandler('module'); - echo "
"; - echo $GLOBALS['xoopsSecurity']->getTokenHTML(); - echo " - - '; - $block_arr = \XoopsBlock::getByModule($xoopsModule->mid()); - $block_count = count($block_arr); - $class = 'even'; - $cachetimes = [ - '0' => _NOCACHE, - '30' => sprintf(_SECONDS, 30), - '60' => _MINUTE, - '300' => sprintf(_MINUTES, 5), - '1800' => sprintf(_MINUTES, 30), - '3600' => _HOUR, - '18000' => sprintf(_HOURS, 5), - '86400' => _DAY, - '259200' => sprintf(_DAYS, 3), - '604800' => _WEEK, - '2592000' => _MONTH, - ]; - foreach ($block_arr as $i) { - $groups_perms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); - $result = $db->query($sql); - $modules = []; - while (false !== ($row = $db->fetchArray($result))) { - $modules[] = (int)$row['module_id']; - } - - $cachetime_options = ''; - foreach ($cachetimes as $cachetime => $cachetime_name) { - if ($i->getVar('bcachetime') == $cachetime) { - $cachetime_options .= "\n"; - } else { - $cachetime_options .= "\n"; - } - } - - $sel0 = $sel1 = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = ''; - if (1 === $i->getVar('visible')) { - $sel1 = ' checked'; - } else { - $sel0 = ' checked'; - } - if (XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) { - $ssel0 = ' checked'; - } elseif (XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) { - $ssel1 = ' checked'; - } elseif (XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) { - $ssel2 = ' checked'; - } elseif (XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) { - $ssel4 = ' checked'; - } elseif (XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) { - $ssel3 = ' checked'; - } elseif (XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) { - $ssel5 = ' checked'; - } elseif (XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) { - $ssel6 = ' checked'; - } elseif (XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) { - $ssel7 = ' checked'; - } - if ('' === $i->getVar('title')) { - $title = ' '; - } else { - $title = $i->getVar('title'); - } - $name = $i->getVar('name'); - echo "'; - - echo "'; - - echo "'; - - // Cache lifetime - echo ''; - - // Actions - - echo " - "; - $class = ('even' === $class) ? 'odd' : 'even'; - } - echo "
" - . constant('CO_' . $moduleDirNameUpper . '_' . 'TITLE') - . "" - . constant('CO_' . $moduleDirNameUpper . '_' . 'SIDE') - . '
' - . _LEFT - . '-' - . _CENTER - . '-' - . _RIGHT - . "
" - . constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT') - . "" - . constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE') - . "" - . _AM_SYSTEM_BLOCKS_VISIBLEIN - . "" - . _AM_SYSTEM_ADGS - . "" - . _AM_SYSTEM_BLOCKS_BCACHETIME - . "" - . constant('CO_' . $moduleDirNameUpper . '_' . 'ACTION') - . '
-
- - - -
-
- -
-
-
- - - -
-
" - . _YES - . " " - . _NO - . ' - " . _EDIT . " - " . _CLONE . " - "; - if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { - echo " getVar('bid') . "'>" . _DELETE . " - "; - } - echo " - - - - - - - -
- - " . $GLOBALS['xoopsSecurity']->getTokenHTML() . " - -
-
-

"; - } - - /** - * @param int $bid - */ - function cloneBlock($bid) - { - require_once __DIR__ . '/admin_header.php'; - //require_once __DIR__ . '/admin_header.php'; - xoops_cp_header(); - - xoops_loadLanguage('admin', 'system'); - xoops_loadLanguage('admin/blocksadmin', 'system'); - xoops_loadLanguage('admin/groups', 'system'); - $myblock = new \XoopsBlock($bid); - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; - $result = $db->query($sql); - $modules = []; - while (false !== ($row = $db->fetchArray($result))) { - $modules[] = (int)$row['module_id']; - } - $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); - $block = [ - 'title' => $myblock->getVar('title') . ' Clone', - 'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'), - 'name' => $myblock->getVar('name'), - 'side' => $myblock->getVar('side'), - 'weight' => $myblock->getVar('weight'), - 'visible' => $myblock->getVar('visible'), - 'content' => $myblock->getVar('content', 'N'), - 'modules' => $modules, - 'is_custom' => $is_custom, - 'ctype' => $myblock->getVar('c_type'), - 'bcachetime' => $myblock->getVar('bcachetime'), - 'op' => 'clone_ok', - 'bid' => $myblock->getVar('bid'), - 'edit_form' => $myblock->getOptions(), - 'template' => $myblock->getVar('template'), - 'options' => $myblock->getVar('options'), - ]; - echo '' . _AM_BADMIN . ' »» ' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '

'; - require_once __DIR__ . '/blockform.php'; - $form->display(); - require_once __DIR__ . '/admin_footer.php'; - exit(); - } - - /** - * @param int $bid - * @param string $bside - * @param int $bweight - * @param bool $bvisible - * @param int $bcachetime - * @param array $bmodule - * @param null|array|string $options - */ - function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options) - { - xoops_loadLanguage('admin', 'system'); - xoops_loadLanguage('admin/blocksadmin', 'system'); - xoops_loadLanguage('admin/groups', 'system'); - - $block = new \XoopsBlock($bid); - $clone = $block->xoopsClone(); - if (empty($bmodule)) { - xoops_cp_header(); - xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); - xoops_cp_footer(); - exit(); - } - $clone->setVar('side', $bside); - $clone->setVar('weight', $bweight); - $clone->setVar('visible', $bvisible); - //$clone->setVar('content', $_POST['bcontent']); - $clone->setVar('title', Request::getString('btitle', '', 'POST')); - $clone->setVar('bcachetime', $bcachetime); - if (isset($options) && (count($options) > 0)) { - $options = implode('|', $options); - $clone->setVar('options', $options); - } - $clone->setVar('bid', 0); - if ('C' === $block->getVar('block_type') || 'E' === $block->getVar('block_type')) { - $clone->setVar('block_type', 'E'); - } else { - $clone->setVar('block_type', 'D'); - } - $newid = $clone->store(); - if (!$newid) { - xoops_cp_header(); - $clone->getHtmlErrors(); - xoops_cp_footer(); - exit(); - } - if ('' !== $clone->getVar('template')) { - /** @var \XoopsTplfileHandler $tplfileHandler */ - $tplfileHandler = xoops_getHandler('tplfile'); - $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); - if (count($btemplate) > 0) { - $tplclone = $btemplate[0]->xoopsClone(); - $tplclone->setVar('tpl_id', 0); - $tplclone->setVar('tpl_refid', $newid); - $tplfileHandler->insert($tplclone); - } - } - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - foreach ($bmodule as $bmid) { - $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; - $db->query($sql); - } - $groups = &$GLOBALS['xoopsUser']->getGroups(); - $count = count($groups); - for ($i = 0; $i < $count; ++$i) { - $sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')"; - $db->query($sql); - } - redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED); - } - - /** - * @param int $bid - * @param string $title - * @param int $weight - * @param bool $visible - * @param string $side - * @param int $bcachetime - */ - function setOrder($bid, $title, $weight, $visible, $side, $bcachetime) - { - $myblock = new \XoopsBlock($bid); - $myblock->setVar('title', $title); - $myblock->setVar('weight', $weight); - $myblock->setVar('visible', $visible); - $myblock->setVar('side', $side); - $myblock->setVar('bcachetime', $bcachetime); - $myblock->store(); - } - - /** - * @param int $bid - */ - function editBlock($bid) - { - require_once __DIR__ . '/admin_header.php'; - //require_once __DIR__ . '/admin_header.php'; - xoops_cp_header(); - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName - xoops_loadLanguage('admin', 'system'); - xoops_loadLanguage('admin/blocksadmin', 'system'); - xoops_loadLanguage('admin/groups', 'system'); +/** @var \XoopsMySQLDatabase $xoopsDB */ +$xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); +$xoopsSecurity = new \XoopsSecurity(); - $myblock = new \XoopsBlock($bid); - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; - $result = $db->query($sql); - $modules = []; - while (false !== ($row = $db->fetchArray($result))) { - $modules[] = (int)$row['module_id']; - } - $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); - $block = [ - 'title' => $myblock->getVar('title'), - 'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK'), - // 'name' => $myblock->getVar('name'), - 'side' => $myblock->getVar('side'), - 'weight' => $myblock->getVar('weight'), - 'visible' => $myblock->getVar('visible'), - 'content' => $myblock->getVar('content', 'N'), - 'modules' => $modules, - 'is_custom' => $is_custom, - 'ctype' => $myblock->getVar('c_type'), - 'bcachetime' => $myblock->getVar('bcachetime'), - 'op' => 'edit_ok', - 'bid' => $myblock->getVar('bid'), - 'edit_form' => $myblock->getOptions(), - 'template' => $myblock->getVar('template'), - 'options' => $myblock->getVar('options'), - ]; - echo '' . _AM_BADMIN . ' »» ' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '

'; - require_once __DIR__ . '/blockform.php'; - $form->display(); - require_once __DIR__ . '/admin_footer.php'; - exit(); - } +$blocksadmin = new Blocksadmin($xoopsDB, $helper, $xoopsModule, $xoopsSecurity); - /** - * @param int $bid - * @param $btitle - * @param $bside - * @param $bweight - * @param $bvisible - * @param $bcachetime - * @param $bmodule - * @param $options - * @param $groups - */ - function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups) - { - $myblock = new XoopsBlock($bid); - $myblock->setVar('title', $btitle); - $myblock->setVar('weight', $bweight); - $myblock->setVar('visible', $bvisible); - $myblock->setVar('side', $bside); - $myblock->setVar('bcachetime', $bcachetime); - //update block options - if (isset($options)) { - $options_count = count($options); - if ($options_count > 0) { - //Convert array values to comma-separated - for ($i = 0; $i < $options_count; ++$i) { - if (is_array($options[$i])) { - $options[$i] = implode(',', $options[$i]); - } - } - $options = implode('|', $options); - $myblock->setVar('options', $options); - } - } - $myblock->store(); +// Call the handleActions method +$op = Request::getCmd('op', 'list'); - global $xoopsDB; +// Instantiate the BlockActionsHandler +$blockActionsHandler = new BlockActionsHandler($blocksadmin); - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName - - if (!empty($bmodule) && count($bmodule) > 0) { - $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $xoopsDB->prefix('block_module_link'), $bid); - $xoopsDB->query($sql); - if (in_array(0, $bmodule)) { - $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $xoopsDB->prefix('block_module_link'), $bid, 0); - $xoopsDB->query($sql); - } else { - foreach ($bmodule as $bmid) { - $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $xoopsDB->prefix('block_module_link'), $bid, (int)$bmid); - $xoopsDB->query($sql); - } - } - } - $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $xoopsDB->prefix('group_permission'), $bid); - $xoopsDB->query($sql); - if (!empty($groups)) { - foreach ($groups as $grp) { - $sql = sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $xoopsDB->prefix('group_permission'), $grp, $bid); - $xoopsDB->query($sql); - } - } - redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); - } - - if ('list' === $op) { - xoops_cp_header(); - // mpu_adm_menu(); - listBlocks(); - require_once __DIR__ . '/admin_footer.php'; - exit(); - } +// Instantiate the Block DTO +$blockData = $blockActionsHandler->processPostData(); +$blockData->op = $op; +$blockActionsHandler->handleActions($blockData); if ('order' === $op) { - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 3, implode('
', $GLOBALS['xoopsSecurity']->getErrors())); - } - foreach (array_keys($bid) as $i) { - if ($oldtitle[$i] != $title[$i] || $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] - || $oldside[$i] != $side[$i] - || $oldbcachetime[$i] != $bcachetime[$i]) { - setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]); - } - if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) { - $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $xoopsDB->prefix('block_module_link'), $bid[$i]); - $xoopsDB->query($sql); - if (in_array(0, $bmodule[$i])) { - $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $xoopsDB->prefix('block_module_link'), $bid[$i], 0); - $xoopsDB->query($sql); - } else { - foreach ($bmodule[$i] as $bmid) { - $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $xoopsDB->prefix('block_module_link'), $bid[$i], (int)$bmid); - $xoopsDB->query($sql); - } - } - } - $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $xoopsDB->prefix('group_permission'), $bid[$i]); - $xoopsDB->query($sql); - if (!empty($groups[$i])) { - foreach ($groups[$i] as $grp) { - $sql = sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $xoopsDB->prefix('group_permission'), $grp, $bid[$i]); - $xoopsDB->query($sql); - } - } - } - redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); - } - if ('clone' === $op) { - cloneBlock($bid); - } - - if ('edit' === $op) { - editBlock($bid); + $blockActionsHandler->processOrderBlockAction($blockData); } - if ('edit_ok' === $op) { - updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); - } - - if ('clone_ok' === $op) { - isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options); - } -} else { - echo constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'); -} +require __DIR__ . '/admin_footer.php'; diff --git a/admin/feedback.php b/admin/feedback.php index bf90be4..c90501e 100644 --- a/admin/feedback.php +++ b/admin/feedback.php @@ -1,4 +1,4 @@ - + * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) + * @author Michael Beck * @author Wedega - Email: * @author Fernando Santos (topet05) */ +use Xmf\Module\Admin; use Xmf\Request; use XoopsModules\Xoopspoll\{ Common }; -include __DIR__ . '/admin_header.php'; +require __DIR__ . '/admin_header.php'; -$adminObject = \Xmf\Module\Admin::getInstance(); +$adminObject = Admin::getInstance(); $feedback = new Common\ModuleFeedback(); // It recovered the value of argument op in URL$ -$op = Request::getString('op', 'list'); -$moduleDirName = $GLOBALS['xoopsModule']->getVar('dirname'); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$op = Request::getString('op', 'list'); +$moduleDirName = $GLOBALS['xoopsModule']->getVar('dirname'); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); xoops_loadLanguage('feedback', $moduleDirName); xoops_cp_header(); @@ -48,7 +49,6 @@ $form = $feedback->getFormFeedback(); $form->display(); break; - case 'send': // Security Check if (!$GLOBALS['xoopsSecurity']->check()) { @@ -98,4 +98,4 @@ break; } -require __DIR__ . '/admin_footer.php'; +require_once __DIR__ . '/admin_footer.php'; diff --git a/admin/index.html b/admin/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/admin/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/index.php b/admin/index.php index 0c79185..02c3a10 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,4 +1,4 @@ -getHandler('Poll'); $totalPolls = $pollHandler->getCount(); @@ -72,73 +75,24 @@ $adminObject->displayNavigation(basename(__FILE__)); -//------------- Test Data ---------------------------- - +//------------- Test Data Buttons ---------------------------- if ($helper->getConfig('displaySampleButton')) { - $yamlFile = dirname(__DIR__) . '/config/admin.yml'; - $config = loadAdminConfig($yamlFile); - $displaySampleButton = $config['displaySampleButton']; - - if (1 == $displaySampleButton) { - xoops_loadLanguage('admin/modulesadmin', 'system'); - require_once dirname(__DIR__) . '/testdata/index.php'; - - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); - // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); - } else { - $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); - $displaySampleButton = $config['displaySampleButton']; - } + TestdataButtons::loadButtonConfig($adminObject); $adminObject->displayButton('left', ''); } - -//------------- End Test Data ---------------------------- - -$adminObject->displayIndex(); - -/** - * @param $yamlFile - * @return array|bool - */ -function loadAdminConfig($yamlFile) -{ - $config = \Xmf\Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps - return $config; -} - -/** - * @param $yamlFile - */ -function hideButtons($yamlFile) -{ - $app['displaySampleButton'] = 0; - \Xmf\Yaml::save($app, $yamlFile); - redirect_header('index.php', 0, ''); -} - -/** - * @param $yamlFile - */ -function showButtons($yamlFile) -{ - $app['displaySampleButton'] = 1; - \Xmf\Yaml::save($app, $yamlFile); - redirect_header('index.php', 0, ''); -} - $op = Request::getString('op', 0, 'GET'); - switch ($op) { case 'hide_buttons': - hideButtons($yamlFile); + TestdataButtons::hideButtons(); break; case 'show_buttons': - showButtons($yamlFile); + TestdataButtons::showButtons(); break; } +//------------- End Test Data Buttons ---------------------------- +$adminObject->displayIndex(); echo $utility::getServerStats(); -require __DIR__ . '/admin_footer.php'; +//codeDump(__FILE__); +require_once __DIR__ . '/admin_footer.php'; diff --git a/admin/main.php b/admin/main.php index 4b5f8e0..9b68214 100644 --- a/admin/main.php +++ b/admin/main.php @@ -1,4 +1,4 @@ -icons; + $op = Request::getString('op', Request::getCmd('op', 'list', 'POST'), 'GET'); switch ($op) { case 'list': @@ -84,7 +88,7 @@ $pollsCount = count($pollObjs); xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $xoopsTpl->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); $adminObject->addItemButton(_AM_XOOPSPOLL_CREATENEWPOLL, 'main.php' . '?op=add', $icon = 'add'); @@ -141,13 +145,13 @@ $checked = (Constants::DISPLAY_POLL_IN_BLOCK === $pollVars['display']) ? ' checked' : ''; $xuCurrentTimestamp = xoops_getUserTimestamp(time()); - $xuCurrentFormatted = ucfirst(date(_MEDIUMDATESTRING, $xuCurrentTimestamp)); + $xuCurrentFormatted = ucfirst(date(_MEDIUMDATESTRING, (int)$xuCurrentTimestamp)); $xuStartTimestamp = xoops_getUserTimestamp($pollVars['start_time']); - $xuStartFormattedTime = ucfirst(date(_MEDIUMDATESTRING, $xuStartTimestamp)); + $xuStartFormattedTime = ucfirst(date(_MEDIUMDATESTRING, (int)$xuStartTimestamp)); $xuEndTimestamp = xoops_getUserTimestamp($pollVars['end_time']); if ($xuEndTimestamp > $xuCurrentTimestamp) { - $end = ucfirst(date(_MEDIUMDATESTRING, $xuEndTimestamp)); // formatted output for current user + $end = ucfirst(date(_MEDIUMDATESTRING, (int)$xuEndTimestamp)); // formatted output for current user } else { $end = "" . _AM_XOOPSPOLL_EXPIRED . '
' . "" . _AM_XOOPSPOLL_RESTART . ''; } @@ -210,11 +214,11 @@ $optionHandler = $helper->getHandler('Option'); $pollHandler = $helper->getHandler('Poll'); $pollId = Request::getInt('poll_id', 0); - $pollObj = $pollHandler->get($pollId); // will auto create object if poll_id=0 + $pollObj = $pollHandler->get($pollId); // will auto create object if poll_id=0 // display the form xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $adminObject->displayNavigation(basename(__FILE__)); $pollObj->renderForm($_SERVER['SCRIPT_NAME'], 'post'); require_once __DIR__ . '/admin_footer.php'; @@ -312,19 +316,19 @@ $pollId = Request::getInt('poll_id', 0); $pollHandler = $helper->getHandler('Poll'); $pollObj = $pollHandler->get($pollId); - if (empty($pollObj) || !($pollObj instanceof Poll)) { + if (!($pollObj instanceof Poll)) { redirect_header($_SERVER['SCRIPT_NAME'], Constants::REDIRECT_DELAY_SHORT, implode('
', $pollHandler->getErrors())); } xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $adminObject->displayNavigation(basename(__FILE__)); xoops_confirm( [ - 'op' => 'delete_ok', + 'op' => 'delete_ok', 'poll_id' => $pollId, ], $_SERVER['SCRIPT_NAME'], - sprintf(_AM_XOOPSPOLL_RUSUREDEL, $myts->htmlSpecialChars($pollObj->getVar('question'))) + sprintf(_AM_XOOPSPOLL_RUSUREDEL, htmlspecialchars($pollObj->getVar('question'), ENT_QUOTES | ENT_HTML5)) ); require_once __DIR__ . '/admin_footer.php'; // xoops_cp_footer(); @@ -352,7 +356,7 @@ $moduleHandler = xoops_getHandler('module'); $newbbModule = $moduleHandler->getByDirname('newbb'); if (($newbbModule instanceof XoopsModule) && $newbbModule->isactive()) { - /** @var NewbbTopicHandler $topicHandler */ + /** @var Newbb\TopicHandler $topicHandler */ $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('poll_id', $pollId, '=')); @@ -372,7 +376,7 @@ // setup times for forms $xuCurrentTimestamp = xoops_getUserTimestamp(time()); - $xuCurrentFormatted = ucfirst(date(_MEDIUMDATESTRING, $xuCurrentTimestamp)); + $xuCurrentFormatted = ucfirst(date(_MEDIUMDATESTRING, (int)$xuCurrentTimestamp)); $xuStartTimestamp = $xuCurrentTimestamp; $xuEndTimestamp = $xuStartTimestamp + Constants::DEFAULT_POLL_DURATION; @@ -394,7 +398,7 @@ $pollForm->addElement(new \XoopsFormButton('', 'poll_submit', _AM_XOOPSPOLL_RESTART, 'submit')); xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $adminObject->displayNavigation(basename(__FILE__)); $pollForm->display(); require_once __DIR__ . '/admin_footer.php'; @@ -463,11 +467,11 @@ $pollObj = $pollHandler->get($pollId); $expiredClass = ($pollObj->getVar('end_time') < time()) ? ' red' : ''; xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); $adminObject->displayNavigation(basename(__FILE__)); $xuEndTimestamp = userTimeToServerTime($pollObj->getVar('end_time')); - $xuEndFormattedTime = ucfirst(date(_MEDIUMDATESTRING, $xuEndTimestamp)); + $xuEndFormattedTime = ucfirst(date(_MEDIUMDATESTRING, (int)$xuEndTimestamp)); /** * @todo need to move this html to a template and pass variables via xoopsTpl @@ -616,8 +620,8 @@ $pmLink = $GLOBALS['xoops']->buildUrl( $GLOBALS['xoops']->path('pmlite.php', true), [ - 'send' => 1, - 'from_userid' => $from_userid, + 'send' => 1, + 'from_userid' => $from_userid, 'to_userid' => $to_userid, ] ); @@ -640,7 +644,7 @@ echo " {$GLOBALS['xoopsConfig']['anonymous']}\n"; } $xuLogTimestamp = userTimeToServerTime($logVals['time']); - $xuLogFormattedTime = ucfirst(date(_DATESTRING, $xuLogTimestamp)); + $xuLogFormattedTime = ucfirst(date(_DATESTRING, (int)$xuLogTimestamp)); echo " {$xuLogFormattedTime}\n" . " \n"; $class = ('odd' === $class) ? 'even' : 'odd'; @@ -702,8 +706,8 @@ $pollHandler = $helper->getHandler('Poll'); $optionHandler = $helper->getHandler('Option'); $pollId = Request::getInt('poll_id', 0); - $pollObj = $pollHandler->get($pollId); - $origValues = $pollObj->getValues(); + $pollObj = $pollHandler->get($pollId); + $origValues = $pollObj->getValues(); unset($origValues['poll_id']); $pollDuration = $origValues['end_time'] - $origValues['start_time']; $pollDuration = ($pollDuration > 0) ? $pollDuration : Constants::DEFAULT_POLL_DURATION; diff --git a/admin/menu.php b/admin/menu.php index 717ea56..9490f20 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -1,4 +1,4 @@ -loadLanguage('common'); $helper->loadLanguage('feedback'); -$pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); -if (is_object($helper->getModule())) { - $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); +$pathIcon32 = Admin::menuIconPath(''); +$pathModIcon32 = XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icons/32/'; +if (is_object($helper->getModule()) && false !== $helper->getModule()->getInfo('modicons32')) { + $pathModIcon32 = $helper->url($helper->getModule()->getInfo('modicons32')); } /** @@ -81,15 +81,15 @@ // Blocks Admin $adminmenu[] = [ 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS'), - 'link' => 'admin/blocksadmin.php', - 'icon' => $pathIcon32 . '/block.png', + 'link' => 'admin/blocksadmin.php', + 'icon' => $pathIcon32 . '/block.png', ]; if (is_object($helper->getModule()) && $helper->getConfig('displayDeveloperTools')) { $adminmenu[] = [ 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE'), - 'link' => 'admin/migrate.php', - 'icon' => $pathIcon32 . '/database_go.png', + 'link' => 'admin/migrate.php', + 'icon' => $pathIcon32 . '/database_go.png', ]; } diff --git a/admin/migrate.php b/admin/migrate.php index 2efef35..2d60ada 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -1,9 +1,9 @@ - // +// // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // @@ -25,33 +25,35 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // // Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, https://xoops.org/, http://jp.xoops.org/ // +// URL: https://www.myweb.ne.jp/, https://xoops.org/, https://jp.xoops.org/ // // Project: XOOPS Project // // ------------------------------------------------------------------------- // +use Xmf\Module\Admin; use Xmf\Request; use XoopsModules\Xoopspoll\{ Common }; +/** @var Admin $adminObject */ require_once __DIR__ . '/admin_header.php'; xoops_cp_header(); $adminObject->displayNavigation(basename(__FILE__)); echo << -
- -
-
- -
-
- -
- -EOF; +
+
+ +
+
+ +
+
+ +
+
+ EOF; //XoopsLoad::load('migrate', 'newbb'); @@ -59,13 +61,13 @@ $migrator = new Common\Migrate($configurator); -$op = Request::getCmd('op', 'show'); -$opShow = Request::getCmd('show', null, 'POST'); -$opMigrate = Request::getCmd('migrate', null, 'POST'); -$opSchema = Request::getCmd('schema', null, 'POST'); -$op = !empty($opShow) ? 'show' : $op; -$op = !empty($opMigrate) ? 'migrate' : $op; -$op = !empty($opSchema) ? 'schema' : $op; +$op = Request::getCmd('op', 'show'); +$opShow = Request::getCmd('show', '', 'POST'); +$opMigrate = Request::getCmd('migrate', '', 'POST'); +$opSchema = Request::getCmd('schema', '', 'POST'); +$op = !empty($opShow) ? 'show' : $op; +$op = !empty($opMigrate) ? 'migrate' : $op; +$op = !empty($opSchema) ? 'schema' : $op; $message = ''; diff --git a/admin/utility.php b/admin/utility.php index 1e59957..828c5c3 100644 --- a/admin/utility.php +++ b/admin/utility.php @@ -1,4 +1,4 @@ -assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); @@ -77,6 +77,7 @@ try { if (false !== $umModule && $umModule->isactive()) { // make sure the umfrage database tables exist + /** @var \XoopsConfigHandler $configHandler */ $configHandler = xoops_getHandler('config'); $umModuleConfig = $configHandler->getConfigsByCat(0, $umModule->getVar('mid')); $success = false; @@ -201,7 +202,7 @@ } } catch (\Exception $e) { xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); echo $adminObject->displayNavigation(basename(__FILE__)); echo "
" . xoops_error($e->getMessage(), _AM_XOOPSPOLL_IMPORT_FAILED) . "
\n"; require_once __DIR__ . '/admin_footer.php'; @@ -209,7 +210,7 @@ } } else { xoops_cp_header(); - $adminObject = \Xmf\Module\Admin::getInstance(); + $adminObject = Admin::getInstance(); echo $adminObject->displayNavigation(basename(__FILE__)); xoops_confirm(['op' => 'umfrage', 'ok' => 1], $_SERVER['SCRIPT_NAME'], _AM_XOOPSPOLL_RUSUREUMFRAGE); require_once __DIR__ . '/admin_footer.php'; diff --git a/assets/css/index.html b/assets/css/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/assets/css/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/css/index.php b/assets/css/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/assets/css/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/images/colorbars/index.php b/assets/images/colorbars/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/assets/images/colorbars/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/images/icons/index.php b/assets/images/icons/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/assets/images/icons/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/images/index.php b/assets/images/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/assets/images/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/index.php b/assets/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/assets/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/assets/js/index.php b/assets/js/index.php new file mode 100644 index 0000000..e5ee072 --- /dev/null +++ b/assets/js/index.php @@ -0,0 +1,2 @@ +history.go(-1); diff --git a/blocks/index.php b/blocks/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/blocks/index.php @@ -0,0 +1,3 @@ +getByDirname('xoopspoll'); - $configHandler = xoops_getHandler('config'); - $this_module_config = $configHandler->getConfigsByCat(0, $thisModule->getVar('mid')); + $thisModule = $moduleHandler->getByDirname('xoopspoll'); + /** @var \XoopsConfigHandler $configHandler */ + $configHandler = xoops_getHandler('config'); + $thisModuleConfig = $configHandler->getConfigsByCat(0, $thisModule->getVar('mid')); $pollHandler = Helper::getInstance()->getHandler('Poll'); $criteria = new \CriteriaCompo(); @@ -81,13 +80,13 @@ function xoopspollBlockMultiShow($options) /** * now check to see if we want to hide polls that were created using newbb */ - if ($this_module_config['hide_forum_polls'] && ($thisModule instanceof \XoopsModule) && $thisModule->isactive()) { + if ($thisModuleConfig['hide_forum_polls'] && ($thisModule instanceof \XoopsModule) && $thisModule->isactive()) { $newbbModule = $moduleHandler->getByDirname('newbb'); if ($newbbModule instanceof \XoopsModule && $newbbModule->isactive()) { /** @var Newbb\TopicHandler $topicHandler */ $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - $tFields = ['topic_id', 'poll_id']; - $tArray = $topicHandler->getAll(new Criteria('topic_haspoll', 0, '>'), $tFields, false); + $tFields = ['topic_id', 'poll_id']; + $tArray = $topicHandler->getAll(new Criteria('topic_haspoll', 0, '>'), $tFields, false); if (!empty($tArray)) { $tcriteria = []; foreach ($tArray as $t) { @@ -115,10 +114,9 @@ function xoopspollBlockMultiShow($options) $block['langComments'] = _MB_XOOPSPOLL_COMMENTS; $block['langComment'] = _MB_XOOPSPOLL_COMMENT; $block['url'] = 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; - $block['dispVotes'] = $this_module_config['disp_vote_nums']; + $block['dispVotes'] = $thisModuleConfig['disp_vote_nums']; $block['thisModuleDir'] = 'xoopspoll'; $block['asList'] = $options[0]; - $optionHandler = Helper::getInstance()->getHandler('Option'); $logHandler = Helper::getInstance()->getHandler('Log'); @@ -136,13 +134,13 @@ function xoopspollBlockMultiShow($options) $pollOptionName = 'option_id'; } - $uid = 0; + $uid = 0; if (isset($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); } $totalVotes = $pollVars['votes']; - $hasVoted = $logHandler->hasVoted($pollVars['poll_id'], xoops_getenv('REMOTE_ADDR'), $uid) ? true : false; + $hasVoted = (bool)$logHandler->hasVoted($pollVars['poll_id'], xoops_getenv('REMOTE_ADDR'), $uid); $canVote = (!$hasVoted) && $pollObj->isAllowedToVote(); foreach ($pollOptionObjs as $pollOptionObj) { $optionObjVars = $pollOptionObj->getValues(); @@ -158,10 +156,10 @@ function xoopspollBlockMultiShow($options) } unset($pollOptionObjs, $optionObjVars); $xuEndTimestamp = xoops_getUserTimestamp($pollObj->getVar('end_time')); - $xuEndFormattedTime = ucfirst(date(_MEDIUMDATESTRING, $xuEndTimestamp)); + $xuEndFormattedTime = ucfirst(date(_MEDIUMDATESTRING, (int)$xuEndTimestamp)); $isVisible = true === $pollObj->isResultVisible(); - $multiple = $pollVars['multiple'] ? true : false; + $multiple = (bool)$pollVars['multiple']; $multiLimit = (int)$pollVars['multilimit']; $lang_multi = ''; if ($multiple && ($multiLimit > 0)) { @@ -197,13 +195,12 @@ function xoopspollBlockMultiShow($options) /** * Display a form to edit poll block display option * - * @access public * @param mixed $options * @return string HTML form for display by block admin * @global mixed $GLOBALS ['xoopsUser'] * @uses xoops_getModuleHandler() function to get class handler for this modules class(es) */ -function xoopspollBlockMultiEdit($options) +function xoopspollBlockMultiEdit(mixed $options): string { /** * Options[] diff --git a/blocks/singlepoll.php b/blocks/singlepoll.php index b3154be..860ed96 100644 --- a/blocks/singlepoll.php +++ b/blocks/singlepoll.php @@ -1,4 +1,4 @@ -getHandler('Poll'); /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $thisModule = $moduleHandler->getByDirname('xoopspoll'); - $this_module_config = $configHandler->getConfigsByCat(0, $thisModule->getVar('mid')); + $moduleHandler = xoops_getHandler('module'); + $thisModule = $moduleHandler->getByDirname('xoopspoll'); + $thisModuleConfig = $configHandler->getConfigsByCat(0, $thisModule->getVar('mid')); /* if admin hasn't initialized block then we'll pick a poll for them * provided that one exists in the database @@ -66,7 +65,7 @@ function xoopspollBlockSinglepollShow($options) /** * check to see if we want to include polls created with forum (newbb) */ - if ($this_module_config['hide_forum_polls'] + if ($thisModuleConfig['hide_forum_polls'] && ($thisModule instanceof \XoopsModule) && $thisModule->isactive()) { $newbbModule = $moduleHandler->getByDirname('newbb'); @@ -113,7 +112,7 @@ function xoopspollBlockSinglepollShow($options) $block['asList'] = $options[3]; $block['thisModuleDir'] = 'xoopspoll'; $block['url'] = 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; - $block['dispVotes'] = $this_module_config['disp_vote_nums']; + $block['dispVotes'] = $thisModuleConfig['disp_vote_nums']; $optionHandler = Helper::getInstance()->getHandler('Option'); @@ -132,14 +131,14 @@ function xoopspollBlockSinglepollShow($options) $pollOptionName = 'option_id'; } - $uid = 0; + $uid = 0; if (isset($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); } $totalVotes = $pollVars['votes']; $logHandler = Helper::getInstance()->getHandler('Log'); - $hasVoted = $logHandler->hasVoted($pollVars['poll_id'], xoops_getenv('REMOTE_ADDR'), $uid) ? true : false; + $hasVoted = (bool)$logHandler->hasVoted($pollVars['poll_id'], xoops_getenv('REMOTE_ADDR'), $uid); $canVote = (!$hasVoted) && $pollObj->isAllowedToVote(); $pollOptionsArray = []; foreach ($optionsObjArray as $optionObj) { @@ -162,11 +161,11 @@ function xoopspollBlockSinglepollShow($options) } $xuEndTimestamp = xoops_getUserTimestamp($pollObj->getVar('end_time')); - $xuEndFormattedTime = ucfirst(date(_MEDIUMDATESTRING, $xuEndTimestamp)); + $xuEndFormattedTime = ucfirst(date(_MEDIUMDATESTRING, (int)$xuEndTimestamp)); $isVisible = true === $pollObj->isResultVisible(); - $multiple = $pollVars['multiple'] ? true : false; + $multiple = (bool)$pollVars['multiple']; $multiLimit = (int)$pollVars['multilimit']; $lang_multi = ''; if ($multiple && ($multiLimit > 0)) { @@ -200,13 +199,12 @@ function xoopspollBlockSinglepollShow($options) /** * Display a form to edit poll block display option * - * @access public * @param mixed $options * @return string HTML form for display by block admin * @global mixed $GLOBALS ['xoopsUser'] * @uses xoops_getModuleHandler() function to get class handler for this modules class(es) */ -function xoopspollBlockSinglepollEdit($options) +function xoopspollBlockSinglepollEdit(mixed $options): string { /** * Options[] @@ -218,7 +216,7 @@ function xoopspollBlockSinglepollEdit($options) * 3 = show options as list|select */ - // find out if want to show expired polls in block + // find out if you want to show expired polls in block // (otherwise it will hide block once it expires) if (0 === $options[0]) { $chk0no = ' checked'; @@ -247,20 +245,24 @@ function xoopspollBlockSinglepollEdit($options) $criteria->setOrder('ASC'); $criteria->setSort('weight'); /** - * Note that you can select polls that have not started yet so they will automatically show + * Note that you can select polls that have not started yet, so they will automatically show * up in the block once they have started. To only allow selection of active polls uncomment * the following line in the code - this could be made a module config option if desired - */ // $criteria->add(new \Criteria('start_time', time(), '<=')); + */ + + // $criteria->add(new \Criteria('start_time', time(), '<=')); + /** * now check to see if we want to hide polls that were created using newbb */ - $configHandler = xoops_getHandler('config'); + /** @var \XoopsConfigHandler $configHandler */ + $configHandler = xoops_getHandler('config'); /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $thisModule = $moduleHandler->getByDirname('xoopspoll'); - $this_module_config = $configHandler->getConfigsByCat(0, $thisModule->getVar('mid')); + $moduleHandler = xoops_getHandler('module'); + $thisModule = $moduleHandler->getByDirname('xoopspoll'); + $thisModuleConfig = $configHandler->getConfigsByCat(0, $thisModule->getVar('mid')); - if ($this_module_config['hide_forum_polls'] && ($thisModule instanceof \XoopsModule) && $thisModule->isactive()) { + if ($thisModuleConfig['hide_forum_polls'] && ($thisModule instanceof \XoopsModule) && $thisModule->isactive()) { $newbbModule = $moduleHandler->getByDirname('newbb'); if ($newbbModule instanceof \XoopsModule && $newbbModule->isactive()) { /** @var Newbb\TopicHandler $topicHandler */ @@ -293,7 +295,7 @@ function xoopspollBlockSinglepollEdit($options) foreach ($allPollsArray as $thisPoll) { $selected = ($thisPoll['poll_id'] === $options[1]) ? ' selected' : ''; $taggedQuestion = ($thisPoll['end_time'] < time()) ? $thisPoll['question'] . '**' : $thisPoll['question']; - $form .= " \n"; + $form .= " \n"; } $form .= "\n" . ' ** - ' . _MB_XOOPSPOLL_EXPIRED_INDICATOR . "\n"; } @@ -318,7 +320,7 @@ function xoopspollBlockSinglepollEdit($options) . "\n" . "\n"; - /* find out if want to show options as a list or as a select box */ + /* find out if you want to show options as a list or as a select box */ if (Constants::POLL_OPTIONS_SELECT === $options[3]) { $chk3select = ' checked'; $chk3list = ''; diff --git a/class/Common/BlockActionsHandler.php b/class/Common/BlockActionsHandler.php new file mode 100644 index 0000000..5106015 --- /dev/null +++ b/class/Common/BlockActionsHandler.php @@ -0,0 +1,177 @@ +blocksadmin = $blocksadmin; + $this->helper = Helper::getInstance(); + } + + public function processPostData(): BlockData + { + $blockData = new BlockData(); + $blockData->ok = Request::getInt('ok', 0, 'POST'); + $blockData->confirm_submit = Request::getCmd('confirm_submit', '', 'POST'); + $blockData->submit = Request::getString('submit', '', 'POST'); + $blockData->bside = Request::getString('bside', '0', 'POST'); + $blockData->bweight = Request::getString('bweight', '0', 'POST'); + $blockData->bvisible = Request::getString('bvisible', '0', 'POST'); + $blockData->bmodule = Request::getArray('bmodule', [], 'POST'); + $blockData->btitle = Request::getString('btitle', '', 'POST'); + $blockData->bcachetime = Request::getString('bcachetime', '0', 'POST'); + $blockData->groups = Request::getArray('groups', [], 'POST'); + $blockData->options = Request::getArray('options', [], 'POST'); + $blockData->submitblock = Request::getString('submitblock', '', 'POST'); + $blockData->fct = Request::getString('fct', '', 'POST'); + $blockData->title = Request::getString('title', '', 'POST'); + $blockData->side = Request::getString('side', '0', 'POST'); + $blockData->weight = Request::getString('weight', '0', 'POST'); + $blockData->visible = Request::getString('visible', '0', 'POST'); + +// $blockData->oldTitle = []; +// $blockData->oldSide = []; +// $blockData->oldWeight = []; +// $blockData->oldVisible = []; +// $blockData->oldGroups = []; +// $blockData->oldBcachetime = []; +// $blockData->oldBmodule = []; + + return $blockData; + } + + public function handleActions(BlockData $blockData) + { + $moduleDirNameUpper = \mb_strtoupper(Helper::getInstance()->getDirname()); + $bid = Request::getInt('bid', 0); + + switch ($blockData->op) { + case 'order': + $blockData->bid = Request::getArray('bid', []); + $blockData->titleArray = Request::getArray('title', [], 'POST'); + // Fill in other properties from the request + $this->processOrderBlockAction($blockData); + break; + + case 'clone': + $this->blocksadmin->cloneBlock($bid); + break; + + case 'delete': + if (1 === $blockData->ok) { + $this->blocksadmin->deleteBlock($bid); + } else { + xoops_confirm(['ok' => 1, 'op' => 'delete', 'bid' => $bid], 'blocksadmin.php', constant('CO_' . $moduleDirNameUpper . '_' . 'DELETE_BLOCK_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); + xoops_cp_footer(); + } + break; + + case 'edit': + if ($bid > 0) { + $this->blocksadmin->editBlock($bid); + } else { + $this->helper->redirect('admin/blocksadmin.php', 3, _AM_BLOCK_EDIT_ID_ERROR); + } + break; + + case 'edit_ok': + $this->blocksadmin->updateBlock($bid, $blockData->btitle, $blockData->bside, $blockData->bweight, $blockData->bvisible, $blockData->bcachetime, $blockData->bmodule, $blockData->options, $blockData->groups); + break; + + case 'clone_ok': + $this->blocksadmin->isBlockCloned($bid, $blockData->bside, $blockData->bweight, $blockData->bvisible, $blockData->bcachetime, $blockData->bmodule, $blockData->options, $blockData->groups, true); + break; + + case 'list': + // xoops_cp_header(); + $this->blocksadmin->listBlocks(); + break; + + default: + // Add the code to handle the default operation here + break; + } + } + + public function processOrderBlockAction(BlockData $blockData) + { + $blockData->bid = Request::getArray('bid', []); + $blockData->oldtitle = Request::getArray('oldtitle', [], 'POST'); + $blockData->oldside = Request::getArray('oldside', [], 'POST'); + $blockData->oldweight = Request::getArray('oldweight', [], 'POST'); + $blockData->oldvisible = Request::getArray('oldvisible', [], 'POST'); + $blockData->oldgroups = Request::getArray('oldgroups', [], 'POST'); + $blockData->oldbcachetime = Request::getArray('oldcachetime', [], 'POST'); + $blockData->oldbmodule = Request::getArray('oldbmodule', [], 'POST'); + $blockData->title = Request::getArray('title', [], 'POST'); + $blockData->weight = Request::getArray('weight', [], 'POST'); + $blockData->visible = Request::getArray('visible', [], 'POST'); + $blockData->side = Request::getArray('side', [], 'POST'); + $blockData->bcachetime = Request::getArray('bcachetime', [], 'POST'); + $blockData->groups = Request::getArray('groups', [], 'POST'); + $blockData->bmodule = Request::getArray('bmodule', [], 'POST'); + + + $this->blocksadmin->orderBlock( + $blockData->bid, + $blockData->oldtitle, + $blockData->oldside, + $blockData->oldweight, + $blockData->oldvisible, + $blockData->oldgroups, + $blockData->oldbcachetime, + $blockData->oldbmodule, + $blockData->title, + $blockData->weight, + $blockData->visible, + $blockData->side, + $blockData->bcachetime, + $blockData->groups, + $blockData->bmodule + ); + } + + + //for testing mocking + + /** + * @param $request + * @return void + */ + public function setRequest($request): void + { + $this->request = $request; + } + +} diff --git a/class/Common/BlockData.php b/class/Common/BlockData.php new file mode 100644 index 0000000..bb6659d --- /dev/null +++ b/class/Common/BlockData.php @@ -0,0 +1,48 @@ +db = $db; + $this->helper = $helper; + $this->xoopsModule = $xoopsModule; + $this->xoopsSecurity = $xoopsSecurity; + $this->moduleDirName = \basename(\dirname(__DIR__, 2)); + $this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName); + \xoops_loadLanguage('admin', 'system'); + \xoops_loadLanguage('admin/blocksadmin', 'system'); + \xoops_loadLanguage('admin/groups', 'system'); + $this->helper->loadLanguage('common'); + $this->helper->loadLanguage('blocksadmin'); + } + + /** + * @return void + */ + public function listBlocks(): void + { + $pathIcon16 = Admin::iconUrl('', '16'); + + require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; + + /** @var \XoopsModuleHandler $moduleHandler */ + $moduleHandler = \xoops_getHandler('module'); + /** @var \XoopsMemberHandler $memberHandler */ + $memberHandler = \xoops_getHandler('member'); + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = \xoops_getHandler('groupperm'); + $groups = $memberHandler->getGroups(); + $criteria = new \CriteriaCompo(new \Criteria('hasmain', '1')); + $criteria->add(new \Criteria('isactive', '1')); + $moduleList = $moduleHandler->getList($criteria); + $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE; + $moduleList[0] = \_AM_SYSTEM_BLOCKS_ALLPAGES; + \ksort($moduleList); + echo "

" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '

'; + echo "
"; + echo $this->xoopsSecurity->getTokenHTML(); + echo " + + + + + + + '; + $blockArray = \XoopsBlock::getByModule($this->xoopsModule->mid()); + $blockCount = \count($blockArray); + $class = 'even'; + $cachetimes = [ + 0 => \_NOCACHE, + 30 => \sprintf(\_SECONDS, 30), + 60 => \_MINUTE, + 300 => \sprintf(\_MINUTES, 5), + 1800 => \sprintf(\_MINUTES, 30), + 3600 => \_HOUR, + 18000 => \sprintf(\_HOURS, 5), + 86400 => \_DAY, + 259200 => \sprintf(\_DAYS, 3), + 604800 => \_WEEK, + 2592000 => \_MONTH, + ]; + foreach ($blockArray as $i) { + $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); + $sql = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); + $result = $this->db->query($sql); + if (!$this->db->isResultSet($result)) { +// \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR); + $errorMsg = \sprintf(_DB_QUERY_ERROR, $sql) . $this->db->error(); + $logger = \XoopsLogger::getInstance(); + $logger->handleError(E_USER_WARNING, $errorMsg, __FILE__, __LINE__); + $this->helper->redirect('admin/blocksadmin.php', 3, $errorMsg); + } + $modules = []; + while (false !== ($row = $this->db->fetchArray($result))) { + $modules[] = (int)$row['module_id']; + } + + $cachetimeOptions = ''; + foreach ($cachetimes as $cachetime => $cachetimeName) { + if ($i->getVar('bcachetime') == $cachetime) { + $cachetimeOptions .= "\n"; + } else { + $cachetimeOptions .= "\n"; + } + } + + $ssel7 = ''; + $ssel6 = $ssel7; + $ssel5 = $ssel6; + $ssel4 = $ssel5; + $ssel3 = $ssel4; + $ssel2 = $ssel3; + $ssel1 = $ssel2; + $ssel0 = $ssel1; + $sel1 = $ssel0; + $sel0 = $sel1; + if (1 === $i->getVar('visible')) { + $sel1 = ' checked'; + } else { + $sel0 = ' checked'; + } + if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) { + $ssel0 = ' checked'; + } elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) { + $ssel1 = ' checked'; + } elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) { + $ssel2 = ' checked'; + } elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) { + $ssel4 = ' checked'; + } elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) { + $ssel3 = ' checked'; + } elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) { + $ssel5 = ' checked'; + } elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) { + $ssel6 = ' checked'; + } elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) { + $ssel7 = ' checked'; + } + if ('' === $i->getVar('title')) { + $title = ' '; + }else { + $title = $i->getVar('title'); + } + $name = $i->getVar('name'); + echo " + + + '; + + echo "'; + + echo "'; + + // Cache lifetime + echo ''; + + // Actions + + echo " + "; + $class = ('even' === $class) ? 'odd' : 'even'; + } + echo " +
" . \_AM_SYSTEM_BLOCKS_TITLE . "" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE') . '
' . _LEFT . '-' . _CENTER . '-' . _RIGHT . "
" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT') . "" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE') . "" . \_AM_SYSTEM_BLOCKS_VISIBLEIN . "" . \_AM_SYSTEM_ADGS . "" . \_AM_SYSTEM_BLOCKS_BCACHETIME . "" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION') . '
+ + + +
+
+ +
+
+
+ + + +
+
" . \_YES . " " . \_NO . ' + + " . \_EDIT . " + " . \_CLONE . ""; + // if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { + // echo " getVar('bid') . "'>" . _DELETE . " + // "; + // } + + // if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { + if (!\in_array($i->getVar('block_type'), ['M', 'S'])) { + echo "  + " . \_DELETE . " + "; + } + echo " + + + + + + + +
+ " . $this->xoopsSecurity->getTokenHTML() . " + +
+
+

"; + } + + /** + * @param int $bid + */ + public function deleteBlock(int $bid): void + { + // \xoops_cp_header(); + + \xoops_loadLanguage('admin', 'system'); + \xoops_loadLanguage('admin/blocksadmin', 'system'); + \xoops_loadLanguage('admin/groups', 'system'); + +// $myblock = new \XoopsBlock($bid); + + $sql = \sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $bid); + $result = $this->db->queryF($sql); + if (!$result) { + \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR); + } + $sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid); + $result = $this->db->queryF($sql); + if (!$result) { + \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR); + } + + $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED); + } + + /** + * @param int $bid + */ + public function cloneBlock(int $bid) + { + //require __DIR__ . '/admin_header.php'; + // \xoops_cp_header(); + + \xoops_loadLanguage('admin', 'system'); + \xoops_loadLanguage('admin/blocksadmin', 'system'); + \xoops_loadLanguage('admin/groups', 'system'); + + $myblock = new \XoopsBlock($bid); + $sql = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid; + $result = $this->db->query($sql); + if (!$this->db->isResultSet($result)) { + $errorMsg = \sprintf(_DB_QUERY_ERROR, $sql) . $this->db->error(); + $logger = \XoopsLogger::getInstance(); + $logger->handleError(E_USER_WARNING, $errorMsg, __FILE__, __LINE__); + $this->helper->redirect('admin/blocksadmin.php', 3, $errorMsg); + } + $modules = []; + while (false !== ($row = $this->db->fetchArray($result))) { + $modules[] = (int)$row['module_id']; + } + + $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']); + $block = [ + 'title' => $myblock->getVar('title') . ' Clone', + 'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'), + 'name' => $myblock->getVar('name'), + 'side' => $myblock->getVar('side'), + 'weight' => $myblock->getVar('weight'), + 'visible' => $myblock->getVar('visible'), + 'content' => $myblock->getVar('content', 'N'), + 'modules' => $modules, + 'is_custom' => $isCustom, + 'ctype' => $myblock->getVar('c_type'), + 'bcachetime' => $myblock->getVar('bcachetime'), + 'op' => 'clone_ok', + 'bid' => $myblock->getVar('bid'), + 'edit_form' => $myblock->getOptions(), + 'template' => $myblock->getVar('template'), + 'options' => $myblock->getVar('options'), + ]; + echo '' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . ' »» ' . \_AM_SYSTEM_BLOCKS_CLONEBLOCK . '

'; + // $form = new Blockform(); + // $form->render(); + + $output = $this->render($block); + echo $output; + // xoops_cp_footer(); + // require_once __DIR__ . '/admin_footer.php'; + // exit(); + } + + /** + * @param int $bid + * @param string $bside + * @param string $bweight + * @param string $bvisible + * @param string $bcachetime + * @param array|null $bmodule + * @param array|null $options + * @param array|null $groups + * @param bool $redirect + */ + public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups, bool $redirect = true) + { + \xoops_loadLanguage('admin', 'system'); + \xoops_loadLanguage('admin/blocksadmin', 'system'); + \xoops_loadLanguage('admin/groups', 'system'); + + $block = new \XoopsBlock($bid); + /** @var \XoopsBlock $clone */ + $clone = $block->xoopsClone($bid); +// if (empty($bmodule)) { +// // \xoops_cp_header(); +// \xoops_error(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); +// \xoops_cp_footer(); +// exit(); +// } + + if (empty($bmodule)) { + throw new \InvalidArgumentException(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); + } + $clone->setVar('side', $bside); + $clone->setVar('weight', $bweight); + $clone->setVar('visible', $bvisible); + //$clone->setVar('content', $_POST['bcontent']); + $clone->setVar('title', Request::getString('btitle', '', 'POST')); + $clone->setVar('bcachetime', $bcachetime); + if (\is_array($options) && (\count($options) > 0)) { + $options = \implode('|', $options); + $clone->setVar('options', $options); + } + $clone->setVar('bid', 0); + if (\in_array($block->getVar('block_type'), ['C', 'E'])) { + $clone->setVar('block_type', 'E'); + } else { + $clone->setVar('block_type', 'D'); + } + $newid = null; + // $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105 + if ($clone->store()) { + $newid = $clone->id(); //get the id of the cloned block + } +// if (!$newid) { +// // \xoops_cp_header(); +// $clone->getHtmlErrors(); +// \xoops_cp_footer(); +// exit(); +// } + + if (!$newid) { + throw new \RuntimeException($clone->getHtmlErrors()); + } + + if ('' !== $clone->getVar('template')) { + + /** @var \XoopsTplfileHandler $tplfileHandler */ + $tplfileHandler = \xoops_getHandler('tplfile'); + $configHandler = xoops_getHandler('config'); + /** @var \XoopsConfigHandler $xoopsConfig */ + $xoopsConfig = $configHandler->getConfigsByCat(XOOPS_CONF); + $btemplate = $tplfileHandler->find($xoopsConfig['template_set'], 'block', (string)$bid); + if (\count($btemplate) > 0) { + $tplclone = $btemplate[0]->xoopsClone(); + $tplclone->setVar('tpl_id', 0); + $tplclone->setVar('tpl_refid', $newid); + $tplfileHandler->insert($tplclone); + } + } + + foreach ($bmodule as $bmid) { + $sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; + $this->db->query($sql); + } + //$groups = &$this->xoopsUser->getGroups(); + foreach ($groups as $iValue) { + $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')"; + $this->db->query($sql); + } + + if ($redirect) { + $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED); + } + + return true; + } + + /** + * @param string $bid + * @param string $title + * @param string $weight + * @param string $visible + * @param string $side + * @param string $bcachetime + * @param array|null $bmodule + */ + public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void + { + $myblock = new \XoopsBlock($bid); + $myblock->setVar('title', $title); + $myblock->setVar('weight', $weight); + $myblock->setVar('visible', $visible); + $myblock->setVar('side', $side); + $myblock->setVar('bcachetime', $bcachetime); + $myblock->store(); + // /** @var \XoopsBlockHandler $blockHandler */ + // $blockHandler = \xoops_getHandler('block'); + // return $blockHandler->insert($myblock); + } + + /** + * @param int $bid + * @return void + */ + public function editBlock(int $bid): void + { + // require_once \dirname(__DIR__,2) . '/admin/admin_header.php'; + // \xoops_cp_header(); + \xoops_loadLanguage('admin', 'system'); + \xoops_loadLanguage('admin/blocksadmin', 'system'); + \xoops_loadLanguage('admin/groups', 'system'); + // mpu_adm_menu(); + $myblock = new \XoopsBlock($bid); + $sql = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid; + $result = $this->db->query($sql); + if (!$this->db->isResultSet($result)) { + // \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR); + $errorMsg = \sprintf(_DB_QUERY_ERROR, $sql) . $this->db->error(); + $logger = \XoopsLogger::getInstance(); + $logger->handleError(E_USER_WARNING, $errorMsg, __FILE__, __LINE__); + $this->helper->redirect('admin/blocksadmin.php', 3, $errorMsg); + } + $modules = []; + while (false !== ($row = $this->db->fetchArray($result))) { + $modules[] = (int)$row['module_id']; + } + + $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']); + $block = [ + 'title' => $myblock->getVar('title'), + 'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK, + // 'name' => $myblock->getVar('name'), + 'side' => $myblock->getVar('side'), + 'weight' => $myblock->getVar('weight'), + 'visible' => $myblock->getVar('visible'), + 'content' => $myblock->getVar('content', 'N'), + 'modules' => $modules, + 'is_custom' => $isCustom, + 'ctype' => $myblock->getVar('c_type'), + 'bcachetime' => $myblock->getVar('bcachetime'), + 'op' => 'edit_ok', + 'bid' => $myblock->getVar('bid'), + 'edit_form' => $myblock->getOptions(), + 'template' => $myblock->getVar('template'), + 'options' => $myblock->getVar('options'), + ]; + echo '' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . ' »» ' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '

'; + + $output = $this->render($block); + echo $output; + } + + /** + * @param int $bid + * @param string $btitle + * @param string $bside + * @param string $bweight + * @param string $bvisible + * @param string $bcachetime + * @param array|null $bmodule + * @param array|null $options + * @param array|null $groups + */ + public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups) + { + $myblock = new \XoopsBlock($bid); + $myblock->setVar('title', $btitle); + $myblock->setVar('weight', $bweight); + $myblock->setVar('visible', $bvisible); + $myblock->setVar('side', $bside); + $myblock->setVar('bcachetime', $bcachetime); + //update block options + if (isset($options)) { + $optionsCount = \count($options); + if ($optionsCount > 0) { + //Convert array values to comma-separated + foreach ($options as $i => $iValue) { + if (\is_array($iValue)) { + $options[$i] = \implode(',', $iValue); + } + } + $options = \implode('|', $options); + $myblock->setVar('options', $options); + } + } + $newbid = $myblock->store(); + + /** @var \XoopsBlockHandler $blockHandler */ + $blockHandler = \xoops_getHandler('block'); + $blockHandler->insert($myblock); + + if (!empty($bmodule) && \count($bmodule) > 0) { + $sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid); + $this->db->query($sql); + if (\in_array(0, $bmodule)) { + $sql = \sprintf('INSERT INTO %s (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, 0); + $this->db->query($sql); + } else { + foreach ($bmodule as $bmid) { + $sql = \sprintf('INSERT INTO %s (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid); + $this->db->query($sql); + } + } + } + $sql = \sprintf('DELETE FROM %s WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid); + $this->db->query($sql); + if (!empty($groups)) { + foreach ($groups as $grp) { + $sql = \sprintf("INSERT INTO %s (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid); + $this->db->query($sql); + } + } + $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); + } + + /** + * @param array $bid + * @param array $oldtitle + * @param array $oldside + * @param array $oldweight + * @param array $oldvisible +// * @param array $oldgroups + * @param array $oldbcachetime + * @param array $oldbmodule + * @param array $title + * @param array $weight + * @param array $visible + * @param array $side + * @param array $bcachetime + * @param array $groups + * @param array $bmodule + */ + public function orderBlock( + array $bid, + array $oldtitle, + array $oldside, + array $oldweight, + array $oldvisible, +// array $oldgroups, + array $oldbcachetime, + array $oldbmodule, + array $title, + array $weight, + array $visible, + array $side, + array $bcachetime, + array $groups, + array $bmodule + ): void { + if (!$this->xoopsSecurity->check()) { + \redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('
', $this->xoopsSecurity->getErrors())); + } + foreach (\array_keys($bid) as $i) { + if ($oldtitle[$i] !== $title[$i] + || $oldweight[$i] !== $weight[$i] + || $oldvisible[$i] !== $visible[$i] + || $oldside[$i] !== $side[$i] + || $oldbcachetime[$i] !== $bcachetime[$i] + || $oldbmodule[$i] !== $bmodule[$i]) { + $this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]); + } + if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) { + $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]); + $this->db->query($sql); + if (\in_array(0, $bmodule[$i], true)) { + $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], 0); + $this->db->query($sql); + } else { + foreach ($bmodule[$i] as $bmid) { + $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid); + $this->db->query($sql); + } + } + } + $sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid[$i]); + $this->db->query($sql); + if (!empty($groups[$i])) { + foreach ($groups[$i] as $grp) { + $sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid[$i]); + $this->db->query($sql); + } + } + } + + $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); + } + + /** + * @param array|null $block + * @return void + */ + public function render(?array $block = null): void + { + \xoops_load('XoopsFormLoader'); + \xoops_loadLanguage('common', $this->moduleDirNameUpper); + + $form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true); + if (isset($block['name'])) { + $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_NAME, $block['name'])); + } + $sideSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']); + $sideSelect->addOptionArray([ + 0 => \_AM_SYSTEM_BLOCKS_SBLEFT, + 1 => \_AM_SYSTEM_BLOCKS_SBRIGHT, + 3 => \_AM_SYSTEM_BLOCKS_CBLEFT, + 4 => \_AM_SYSTEM_BLOCKS_CBRIGHT, + 5 => \_AM_SYSTEM_BLOCKS_CBCENTER, + 7 => \_AM_SYSTEM_BLOCKS_CBBOTTOMLEFT, + 8 => \_AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT, + 9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM, + ]); + $form->addElement($sideSelect); + $form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight'])); + $form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible'])); + $modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true); + /** @var \XoopsModuleHandler $moduleHandler */ + $moduleHandler = \xoops_getHandler('module'); + $criteria = new \CriteriaCompo(new \Criteria('hasmain', '1')); + $criteria->add(new \Criteria('isactive', '1')); + $moduleList = $moduleHandler->getList($criteria); + $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE; + $moduleList[0] = \_AM_SYSTEM_BLOCKS_ALLPAGES; + \ksort($moduleList); + $modSelect->addOptionArray($moduleList); + $form->addElement($modSelect); + $form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false); + if ($block['is_custom']) { + $textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70); + $textarea->setDescription('' . \_AM_SYSTEM_BLOCKS_USEFULTAGS . '
' . \sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . ''); + $form->addElement($textarea, true); + $ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']); + $ctypeSelect->addOptionArray([ + 'H' => \_AM_SYSTEM_BLOCKS_HTML, + 'P' => \_AM_SYSTEM_BLOCKS_PHP, + 'S' => \_AM_SYSTEM_BLOCKS_AFWSMILE, + 'T' => \_AM_SYSTEM_BLOCKS_AFNOSMILE, + ]); + $form->addElement($ctypeSelect); + } elseif ('' !== $block['template']) { + /** @var \XoopsTplfileHandler $tplfileHandler */ + $tplfileHandler = \xoops_getHandler('tplfile'); + /** @var \XoopsConfigHandler $configHandler */ + $configHandler = xoops_getHandler('config'); + /** @var \XoopsConfigItem $xoopsConfig */ + $xoopsConfig = $configHandler->getConfigsByCat(XOOPS_CONF); + $btemplate = $tplfileHandler->find($xoopsConfig['template_set'], 'block', $block['bid']); + if (\count($btemplate) > 0) { + $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '' . \_AM_SYSTEM_BLOCKS_EDITTPL . '')); + } else { + $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']); + if (\count($btemplate2) > 0) { + $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '' . \_AM_SYSTEM_BLOCKS_EDITTPL . '')); + } + } + } + if (false !== $block['edit_form']) { + $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form'])); + } + $cache_select = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']); + $cache_select->addOptionArray([ + 0 => \_NOCACHE, + 30 => \sprintf(\_SECONDS, 30), + 60 => \_MINUTE, + 300 => \sprintf(\_MINUTES, 5), + 1800 => \sprintf(\_MINUTES, 30), + 3600 => \_HOUR, + 18000 => \sprintf(\_HOURS, 5), + 86400 => \_DAY, + 259200 => \sprintf(\_DAYS, 3), + 604800 => \_WEEK, + 2592000 => \_MONTH, + ]); + $form->addElement($cache_select); + + /** @var \XoopsGroupPermHandler $grouppermHandler */ + $grouppermHandler = \xoops_getHandler('groupperm'); + $groups = $grouppermHandler->getGroupIds('block_read', $block['bid']); + + $form->addElement(new \XoopsFormSelectGroup(\_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true)); + + if (isset($block['bid'])) { + $form->addElement(new \XoopsFormHidden('bid', $block['bid'])); + } + $form->addElement(new \XoopsFormHidden('op', $block['op'])); + $form->addElement(new \XoopsFormHidden('fct', 'blocksadmin')); + $buttonTray = new \XoopsFormElementTray('', ' '); + if ($block['is_custom']) { + $buttonTray->addElement(new \XoopsFormButton('', 'previewblock', \_PREVIEW, 'submit')); + } + + //Submit buttons + $buttonTray = new \XoopsFormElementTray('', ''); + $submitButton = new \XoopsFormButton('', 'submitblock', \_SUBMIT, 'submit'); + $buttonTray->addElement($submitButton); + + $cancelButton = new \XoopsFormButton('', '', \_CANCEL, 'button'); + $cancelButton->setExtra('onclick="history.go(-1)"'); + $buttonTray->addElement($cancelButton); + + $form->addElement($buttonTray); + $form->display(); + } +} diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php index 95be241..3ed2229 100644 --- a/class/Common/Breadcrumb.php +++ b/class/Common/Breadcrumb.php @@ -1,4 +1,4 @@ - - * @package xoopspoll * * Example: - * $breadcrumb = new PedigreeBreadcrumb(); + * $breadcrumb = new Breadcrumb(); * $breadcrumb->addLink( 'bread 1', 'index1.php' ); * $breadcrumb->addLink( 'bread 2', '' ); * $breadcrumb->addLink( 'bread 3', 'index3.php' ); * echo $breadcrumb->render(); */ + /** * Class Breadcrumb */ class Breadcrumb { - public $dirname; - private $bread = []; + public string $dirname; + public array $bread = []; public function __construct() { @@ -45,7 +45,7 @@ public function __construct() * @param string $title * @param string $link */ - public function addLink($title = '', $link = '') + public function addLink(string $title = '', string $link = ''): void { $this->bread[] = [ 'link' => $link, @@ -56,14 +56,13 @@ public function addLink($title = '', $link = '') /** * Render BreadCrumb */ - public function render() + public function render(): void { /* TODO if you want to use the render code below, 1) create ./templates/chess_common_breadcrumb.tpl) 2) add declaration to xoops_version.php */ - /* if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) { require $GLOBALS['xoops']->path('class/theme.php'); diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index 3a25130..f891475 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -1,4 +1,4 @@ -name = $config->name; @@ -56,9 +54,11 @@ public function __construct() $this->oldFiles = $config->oldFiles; $this->oldFolders = $config->oldFolders; $this->renameTables = $config->renameTables; + $this->renameColumns = $config->renameColumns; + $this->moduleStats = $config->moduleStats; $this->modCopyright = $config->modCopyright; - $this->icons = include \dirname(__DIR__, 2) . '/config/icons.php'; - $this->paths = include \dirname(__DIR__, 2) . '/config/paths.php'; + $this->icons = require \dirname(__DIR__, 2) . '/config/icons.php'; + $this->paths = require \dirname(__DIR__, 2) . '/config/paths.php'; } } diff --git a/class/Common/FilesManagement.php b/class/Common/FilesManagement.php index 7025468..5c7280c 100644 --- a/class/Common/FilesManagement.php +++ b/class/Common/FilesManagement.php @@ -1,4 +1,4 @@ - */ trait FilesManagement @@ -24,7 +24,7 @@ trait FilesManagement * * @param string $folder The full path of the directory to check */ - public static function createFolder($folder) + public static function createFolder(string $folder): void { try { if (!\is_dir($folder)) { @@ -44,16 +44,16 @@ public static function createFolder($folder) * @param $folder * @return bool */ - public static function copyFile($file, $folder) + public static function copyFile(string $file, string $folder): bool { return \copy($file, $folder); } /** - * @param $src - * @param $dst + * @param string $src + * @param string $dst */ - public static function recurseCopy($src, $dst) + public static function recurseCopy(string $src, string $dst): void { $dir = \opendir($src); // @mkdir($dst); @@ -82,7 +82,7 @@ public static function recurseCopy($src, $dst) * * @uses \Xmf\Module\Helper::getHelper() */ - public static function deleteDirectory($src) + public static function deleteDirectory(string $src): bool { // Only continue if user is a 'global' Admin if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { @@ -103,8 +103,8 @@ public static function deleteDirectory($src) break; } } elseif (!($success = \unlink($fileInfo->getRealPath()))) { - break; - } + break; + } } // now delete this (sub)directory if all the files are gone if ($success) { @@ -127,7 +127,7 @@ public static function deleteDirectory($src) * * @return bool true on success */ - public static function rrmdir($src) + public static function rrmdir(string $src): bool { // Only continue if user is a 'global' Admin if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { @@ -156,6 +156,7 @@ public static function rrmdir($src) } } $iterator = null; // clear iterator Obj to close file/directory + return \rmdir($src); // remove the directory & return results } @@ -167,7 +168,7 @@ public static function rrmdir($src) * * @return bool true on success */ - public static function rmove($src, $dest) + public static function rmove(string $src, string $dest): bool { // Only continue if user is a 'global' Admin if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { @@ -196,6 +197,7 @@ public static function rmove($src, $dest) } } $iterator = null; // clear iterator Obj to close file/directory + return \rmdir($src); // remove the directory & return results } @@ -210,7 +212,7 @@ public static function rmove($src, $dest) * * @uses \Xmf\Module\Helper::getHelper() */ - public static function rcopy($src, $dest) + public static function rcopy(string $src, string $dest): bool { // Only continue if user is a 'global' Admin if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index 0abdc9f..ceb3671 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -1,4 +1,4 @@ - * @copyright 2016 XOOPS Project (https://xoops.org) - * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) + * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) * @link https://xoops.org */ class Migrate extends \Xmf\Database\Migrate { - private $renameTables; + private mixed $renameTables; /** * Migrate constructor. @@ -44,7 +44,7 @@ public function __construct(Common\Configurator $configurator = null) /** * change table prefix if needed */ - private function changePrefix() + private function changePrefix(): void { foreach ($this->renameTables as $oldName => $newName) { if ($this->tableHandler->useTable($oldName) && !$this->tableHandler->useTable($newName)) { @@ -59,7 +59,7 @@ private function changePrefix() * @param string $tableName table to convert * @param string $columnName column with IP address */ - private function convertIPAddresses($tableName, $columnName) + private function convertIPAddresses(string $tableName, string $columnName): void { if ($this->tableHandler->useTable($tableName)) { $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName); @@ -77,7 +77,7 @@ private function convertIPAddresses($tableName, $columnName) /** * Move do* columns from newbb_posts to newbb_posts_text table */ - private function moveDoColumns() + private function moveDoColumns(): void { $tableName = 'newbb_posts_text'; $srcTableName = 'newbb_posts'; @@ -101,7 +101,7 @@ private function moveDoColumns() * table and column renames * data conversions */ - protected function preSyncActions() + protected function preSyncActions(): void { // change 'bb' table prefix to 'newbb' $this->changePrefix(); diff --git a/class/Common/ModuleFeedback.php b/class/Common/ModuleFeedback.php index 142303e..7b32311 100644 --- a/class/Common/ModuleFeedback.php +++ b/class/Common/ModuleFeedback.php @@ -1,4 +1,4 @@ - + * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) + * @author Michael Beck * @author Wedega - Email: * @author Fernando Santos (topet05) */ - \defined('XOOPS_ROOT_PATH') || die('Restricted access'); /** * Class Object ModuleFeedback */ -class ModuleFeedback extends \XoopsObject +class ModuleFeedback extends XoopsObject { - public $name = ''; - public $email = ''; - public $site = ''; - public $type = ''; - public $content = ''; + public string $name = ''; + public string $email = ''; + public string $site = ''; + public string $type = ''; + public string $content = ''; /** * Constructor @@ -49,7 +56,7 @@ public function __construct() * * @param null */ - public static function getInstance() + public static function getInstance(): void { static $instance = false; if (!$instance) { @@ -60,35 +67,34 @@ public static function getInstance() /** * @public function getFormFeedback: * provide form for sending a feedback to module author - * @param bool $action - * @return \XoopsThemeForm + * @param bool|string $action */ - public function getFormFeedback($action = false) + public function getFormFeedback($action = false): XoopsThemeForm { - if (false === $action) { + if (!$action) { $action = $_SERVER['REQUEST_URI']; } $moduleDirName = \basename(\dirname(__DIR__, 2)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); // Get Theme Form \xoops_load('XoopsFormLoader'); - $form = new \XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true); + $form = new XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true); $form->setExtra('enctype="multipart/form-data"'); - $recipient = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail')); + $recipient = new XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail')); $recipient->setExtra('disabled="disabled"'); $form->addElement($recipient); - $your_name = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name); + $your_name = new XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name); $your_name->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME_PLACEHOLER') . '"'); $form->addElement($your_name); - $your_site = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site); + $your_site = new XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE'), 'your_site', 50, 255, $this->site); $your_site->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE_PLACEHOLER') . '"'); $form->addElement($your_site); - $your_mail = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email); + $your_mail = new XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL'), 'your_mail', 50, 255, $this->email); $your_mail->setExtra('placeholder="' . \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL_PLACEHOLER') . '"'); $form->addElement($your_mail); - $fbtypeSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type); + $fbtypeSelect = new XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE'), 'fb_type', $this->type); $fbtypeSelect->addOption('', ''); $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_SUGGESTION')); $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_BUGS')); @@ -105,17 +111,17 @@ public function getFormFeedback($action = false) $editorConfigs['width'] = '100%'; $editorConfigs['height'] = '400px'; /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = \xoops_getHandler('module'); - $module = $moduleHandler->getByDirname('system'); + $moduleHandler = \xoops_getHandler('module'); + $module = $moduleHandler->getByDirname('system'); /** @var \XoopsConfigHandler $configHandler */ $configHandler = \xoops_getHandler('config'); $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); $editorConfigs['editor'] = $config['general_editor']; - $editor = new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); + $editor = new XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); $form->addElement($editor, true); - $form->addElement(new \XoopsFormHidden('op', 'send')); - $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); + $form->addElement(new XoopsFormHidden('op', 'send')); + $form->addElement(new XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); return $form; } diff --git a/class/Common/ServerStats.php b/class/Common/ServerStats.php index a3796fc..3fe0249 100644 --- a/class/Common/ServerStats.php +++ b/class/Common/ServerStats.php @@ -1,4 +1,4 @@ - */ trait ServerStats { /** * serverStats() - * - * @return string */ - public static function getServerStats() + public static function getServerStats(): string { //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); $moduleDirName = \basename(\dirname(__DIR__, 2)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); \xoops_loadLanguage('common', $moduleDirName); $html = ''; // $sql = 'SELECT metavalue'; @@ -44,12 +42,14 @@ public static function getServerStats() $html .= '
' . \constant('CO_' . $moduleDirNameUpper . '_' . 'SPHPINI') . "
\n"; $html .= "
    \n"; - $gdlib = \function_exists('gd_info') ? '' . \constant('CO_' . $moduleDirNameUpper . '_' . 'GDON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_' . 'GDOFF') . ''; - $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_' . 'GDLIBSTATUS') . $gdlib; if (\function_exists('gd_info')) { - if (true === ($gdlib = gd_info())) { + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_' . 'GDLIBSTATUS') . '' . \constant('CO_' . $moduleDirNameUpper . '_' . 'GDON') . ''; + $gdlib = \gd_info(); + if (!empty(($gdlib))) { $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_' . 'GDLIBVERSION') . '' . $gdlib['GD Version'] . ''; } + } else { + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_' . 'GDLIBSTATUS') . '' . \constant('CO_' . $moduleDirNameUpper . '_' . 'GDOFF') . ''; } // // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_' . 'ON') . constant('CO_' . $moduleDirNameUpper . '_' . 'SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_' . 'OFF'); diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index b0c29c2..b2d39de 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -1,4 +1,4 @@ - * @author Mamba */ -use MyTextSanitizer; -use XoopsFormDhtmlTextArea; -use XoopsFormTextArea; +use Xmf\Request; use XoopsModules\Xoopspoll\{ Helper }; @@ -35,115 +32,274 @@ */ class SysUtility { - use VersionChecks; + use VersionChecks; //checkVerXoops, checkVerPhp Traits + use ServerStats; // getServerStats Trait + use FilesManagement; // Files Management Trait + // use ModuleStats; // ModuleStats Trait - //checkVerXoops, checkVerPhp Traits + //--------------- Common module methods ----------------------------- - use ServerStats; + /** + * Access the only instance of this class + * + * @return SysUtility + * + */ + public static function getInstance(): self + { + static $instance; + if (null === $instance) { + $instance = new static(); + } + + return $instance; + } + + /** + * @param string $text + * @param string $form_sort + * @return string + */ + public static function selectSorting(string $text, string $form_sort): string + { + global $start, $order, $sort; + + $selectViewForm = ''; + $moduleDirName = \basename(\dirname(__DIR__)); + $helper = Helper::getInstance(); + + //$pathModIcon16 = XOOPS_URL . '/modules/' . $moduleDirName . '/' . $helper->getConfig('modicons16'); + $pathModIcon16 = $helper->url($helper->getModule()->getInfo('modicons16')); + + $selectViewForm = '
    ' . $text . ''; + //$sorts = $sort == 'asc' ? 'desc' : 'asc'; + if ($form_sort == $sort) { + $sel1 = 'asc' === $order ? 'selasc.png' : 'asc.png'; + $sel2 = 'desc' === $order ? 'seldesc.png' : 'desc.png'; + } else { + $sel1 = 'asc.png'; + $sel2 = 'desc.png'; + } + $selectViewForm .= ' ASC'; + $selectViewForm .= 'DESC'; + $selectViewForm .= '
    '; + + return $selectViewForm; + } + + /***************Blocks***************/ + + public static function blockAddCatSelect(array $cats): string + { + $cat_sql = ''; + if (\is_array($cats) && !empty($cats)) { + $cat_sql = '(' . \current($cats); + \array_shift($cats); + foreach ($cats as $cat) { + $cat_sql .= ',' . $cat; + } + $cat_sql .= ')'; + } + + return $cat_sql; + } + + /** + * @param string $content + */ + public static function metaKeywords(string $content): void + { + global $xoopsTpl, $xoTheme; + $myts = \MyTextSanitizer::getInstance(); + $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); + if (\is_object($xoTheme)) { + $xoTheme->addMeta('meta', 'keywords', \strip_tags($content)); + } else { // Compatibility for old Xoops versions + $xoopsTpl->assign('xoops_metaKeywords', \strip_tags($content)); + } + } + + /** + * @param string $content + */ + public static function metaDescription(string $content): void + { + global $xoopsTpl, $xoTheme; + $myts = \MyTextSanitizer::getInstance(); + $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); + if (\is_object($xoTheme)) { + $xoTheme->addMeta('meta', 'description', \strip_tags($content)); + } else { // Compatibility for old Xoops versions + $xoopsTpl->assign('xoops_metaDescription', \strip_tags($content)); + } + } + + /** + * @return array|false + */ + public static function enumerate(string $tableName, string $columnName) + { + $table = $GLOBALS['xoopsDB']->prefix($tableName); - // getServerStats Trait + // $result = $GLOBALS['xoopsDB']->query("SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS + // WHERE TABLE_NAME = '" . $table . "' AND COLUMN_NAME = '" . $columnName . "'") + // || exit ($GLOBALS['xoopsDB']->error()); - use FilesManagement; + $sql = 'SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = "' . $table . '" AND COLUMN_NAME = "' . $columnName . '"'; + $result = $GLOBALS['xoopsDB']->query($sql); + if (!$result) { + // \trigger_error($GLOBALS['xoopsDB']->error()); + $logger = \XoopsLogger::getInstance(); + $logger->handleError(\E_USER_WARNING, $sql, __FILE__, __LINE__); - // Files Management Trait + return false; + } + + $row = $GLOBALS['xoopsDB']->fetchBoth($result); + $enumList = \explode(',', \str_replace("'", '', \mb_substr($row['COLUMN_TYPE'], 5, -6))); + + return $enumList; + } + + /** + * Clone a record in a dB + * + * @TODO need to exit more gracefully on error. Should throw/trigger error and then return false + * + * @param string $tableName name of dB table (without prefix) + * @param string $idField name of field (column) in dB table + * @param int $id item id to clone + * + * @return mixed + */ + public static function cloneRecord(string $tableName, string $idField, int $id): mixed + { + $newId = false; + $table = $GLOBALS['xoopsDB']->prefix($tableName); + // copy content of the record you wish to clone + $sql = "SELECT * FROM $table WHERE $idField='" . $id . "' "; + $tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql), \MYSQLI_ASSOC); + if (!$tempTable) { + \trigger_error($GLOBALS['xoopsDB']->error()); + } + // set the auto-incremented id's value to blank. + unset($tempTable[$idField]); + // insert cloned copy of the original record + $sql = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", $tempTable) . "')"; + $result = $GLOBALS['xoopsDB']->queryF($sql); + if (!$result) { + \trigger_error($GLOBALS['xoopsDB']->error()); + } + // Return the new id + return $GLOBALS['xoopsDB']->getInsertId(); + } /** * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags * www.cakephp.org * - * @param string $text String to truncate. - * @param int $length Length of returned string, including ellipsis. - * @param string $ending Ending to be appended to the trimmed string. - * @param bool $exact If false, $text will not be cut mid-word - * @param bool $considerHtml If true, HTML tags would be handled correctly + * @TODO: Refactor to consider HTML5 & void (self-closing) elements + * @TODO: Consider using https://github.com/jlgrall/truncateHTML/blob/master/truncateHTML.php + * + * @param string $text String to truncate. + * @param int|null $length Length of returned string, including ellipsis. + * @param string|null $ending Ending to be appended to the trimmed string. + * @param bool $exact If false, $text will not be cut mid-word + * @param bool $considerHtml If true, HTML tags would be handled correctly * * @return string Trimmed string. */ - public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) - { + public static function truncateHtml( + string $text, + ?int $length = 100, + ?string $ending = '...', + ?bool $exact = false, + ?bool $considerHtml = true + ): string { + $openTags = []; if ($considerHtml) { // if the plain text is shorter than the maximum length, return the whole text - if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) { + if (\mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) { return $text; } // splits all html-tags to scanable lines \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER); - $total_length = mb_strlen($ending); - $open_tags = []; - $truncate = ''; - foreach ($lines as $line_matchings) { + $totalLength = \mb_strlen($ending); + //$openTags = []; + $truncate = ''; + foreach ($lines as $lineMatchings) { // if there is any html-tag in this line, handle it and add it (uncounted) to the output - if (!empty($line_matchings[1])) { + if (!empty($lineMatchings[1])) { // if it's an "empty element" with or without xhtml-conform closing slash - if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { + if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $lineMatchings[1])) { // do nothing // if tag is a closing tag - } elseif (\preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { - // delete tag from $open_tags list - $pos = \array_search($tag_matchings[1], $open_tags, true); + } elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $lineMatchings[1], $tag_matchings)) { + // delete tag from $openTags list + $pos = \array_search($tag_matchings[1], $openTags, true); if (false !== $pos) { - unset($open_tags[$pos]); + unset($openTags[$pos]); } // if tag is an opening tag - } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) { - // add tag to the beginning of $open_tags list - \array_unshift($open_tags, mb_strtolower($tag_matchings[1])); + } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $lineMatchings[1], $tag_matchings)) { + // add tag to the beginning of $openTags list + \array_unshift($openTags, \mb_strtolower($tag_matchings[1])); } // add html-tag to $truncate'd text - $truncate .= $line_matchings[1]; + $truncate .= $lineMatchings[1]; } // calculate the length of the plain text part of the line; handle entities as one character - $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); - if ($total_length + $content_length > $length) { + $contentLength = \mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', ' ', $lineMatchings[2])); + if ($totalLength + $contentLength > $length) { // the number of characters which are left - $left = $length - $total_length; + $left = $length - $totalLength; $entities_length = 0; // search for html entities - if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) { + if (\preg_match_all('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', $lineMatchings[2], $entities, \PREG_OFFSET_CAPTURE)) { // calculate the real length of all entities in the legal range foreach ($entities[0] as $entity) { if ($left >= $entity[1] + 1 - $entities_length) { $left--; - $entities_length += mb_strlen($entity[0]); + $entities_length += \mb_strlen($entity[0]); } else { // no more characters left break; } } } - $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length); - // maximum lenght is reached, so get off the loop + $truncate .= \mb_substr($lineMatchings[2], 0, $left + $entities_length); + // maximum length is reached, so get off the loop break; } - $truncate .= $line_matchings[2]; - $total_length += $content_length; + $truncate .= $lineMatchings[2]; + $totalLength += $contentLength; // if the maximum length is reached, get off the loop - if ($total_length >= $length) { + if ($totalLength >= $length) { break; } } } else { - if (mb_strlen($text) <= $length) { + if (\mb_strlen($text) <= $length) { return $text; } - $truncate = mb_substr($text, 0, $length - mb_strlen($ending)); + $truncate = \mb_substr($text, 0, $length - \mb_strlen($ending)); } // if the words shouldn't be cut in the middle... if (!$exact) { // ...search the last occurance of a space... - $spacepos = mb_strrpos($truncate, ' '); + $spacepos = \mb_strrpos($truncate, ' '); if (isset($spacepos)) { // ...and cut the text in this position - $truncate = mb_substr($truncate, 0, $spacepos); + $truncate = \mb_substr($truncate, 0, $spacepos); } } // add the defined ending to the text $truncate .= $ending; if ($considerHtml) { // close all unclosed html-tags - foreach ($open_tags as $tag) { + foreach ($openTags as $tag) { $truncate .= ''; } } @@ -152,11 +308,12 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac } /** - * @param null $helper - * @param array|null $options + * Get correct text editor based on user rights + * + * * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor */ - public static function getEditor($helper = null, $options = null) + public static function getEditor(?\Xmf\Module\Helper $helper = null, ?array $options = null) { /** @var Helper $helper */ if (null === $options) { @@ -191,16 +348,70 @@ public static function getEditor($helper = null, $options = null) } /** - * @param $fieldname - * @param $table + * Check if column in dB table exists + * + * @param string $fieldname name of dB table field + * @param string $table name of dB table (including prefix) + * + * @return bool true if table exists + * @deprecated + */ + public static function fieldExists(string $fieldname, string $table): bool + { + $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); + \trigger_error(__METHOD__ . " is deprecated, use Xmf\Database\Tables instead - instantiated from {$trace[0]['file']} line {$trace[0]['line']},"); + + $result = $GLOBALS['xoopsDB']->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); + + return ($GLOBALS['xoopsDB']->getRowsNum($result) > 0); + } + + /** + * Function responsible for checking if a directory exists, we can also write in and create an index.html file + * + * @param string $folder The full path of the directory to check + */ + public static function prepareFolder(string $folder): void + { + try { + if (!@\mkdir($folder) && !\is_dir($folder)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); + } + file_put_contents($folder . '/index.html', ''); + } catch (\Exception $e) { + echo 'Caught exception: ', $e->getMessage(), "\n", '
    '; + } + } + + /** + * Check if dB table exists + * + * @param string $tablename dB tablename with prefix + * @return bool true if table exists + */ + public static function tableExists(string $tablename): bool + { + $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); + \trigger_error(__FUNCTION__ . " is deprecated, called from {$trace[0]['file']} line {$trace[0]['line']}"); + $GLOBALS['xoopsLogger']->addDeprecated( + \basename(\dirname(__DIR__, 2)) . ' Module: ' . __FUNCTION__ . ' function is deprecated, please use Xmf\Database\Tables method(s) instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}" + ); + $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'"); + + return $GLOBALS['xoopsDB']->getRowsNum($result) > 0; + } + + /** + * Add a field to a mysql table * - * @return bool + * @param string $field + * @param string $table + * @return bool|\mysqli_result */ - public function fieldExists($fieldname, $table) + public static function addField(string $field, string $table) { global $xoopsDB; - $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); - return ($xoopsDB->getRowsNum($result) > 0); + return $xoopsDB->queryF('ALTER TABLE ' . $table . " ADD $field;"); } } diff --git a/class/Common/TestdataButtons.php b/class/Common/TestdataButtons.php new file mode 100644 index 0000000..aeb9d88 --- /dev/null +++ b/class/Common/TestdataButtons.php @@ -0,0 +1,93 @@ + + * @copyright {@link https://xoops.org/ XOOPS Project} + * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) + */ + +use Xmf\Yaml; +use XoopsModules\Xoopspoll\Helper; + +/** @var Helper $helper */ + +/** + * Class TestdataButtons + */ +class TestdataButtons +{ + /** Button status constants */ + private const SHOW_BUTTONS = 1; + private const HIDE_BUTTONS = 0; + + /** + * Load the test button configuration + * + * @param \Xmf\Module\Admin $adminObject + * + * @return void + */ + public static function loadButtonConfig(\Xmf\Module\Admin $adminObject): void + { + $moduleDirName = \basename(\dirname(__DIR__, 2)); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + $helper = Helper::getInstance(); + $yamlFile = $helper->path('/config/admin.yml'); + /** @var array $config */ + $config = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps + $displaySampleButton = $config['displaySampleButton']; + + if (self::SHOW_BUTTONS == $displaySampleButton) { + \xoops_loadLanguage('admin/modulesadmin', 'system'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert'); + // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); + } else { + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); + // $displaySampleButton = $config['displaySampleButton']; + } + } + + /** + * Hide the test buttons + * + * @return void + */ + public static function hideButtons(): void + { + $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; + $app = []; + $app['displaySampleButton'] = self::HIDE_BUTTONS; + Yaml::save($app, $yamlFile); + \redirect_header('index.php', 0, ''); + } + + /** + * Show the test buttons + * + * @return void + */ + public static function showButtons(): void + { + $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; + $app = []; + $app['displaySampleButton'] = self::SHOW_BUTTONS; + Yaml::save($app, $yamlFile); + \redirect_header('index.php', 0, ''); + } +} diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index 93a09df..2eb70d2 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -1,4 +1,4 @@ - */ trait VersionChecks @@ -24,13 +24,13 @@ trait VersionChecks * @static * @param \XoopsModule|null $module * - * @param null|string $requiredVer + * @param string|null $requiredVer * @return bool true if meets requirements, false if not */ - public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) + public static function checkVerXoops(\XoopsModule $module = null, string $requiredVer = null): bool { $moduleDirName = \basename(\dirname(__DIR__, 2)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); } @@ -55,14 +55,14 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = /** * Verifies PHP version meets minimum requirements for this module * @static - * @param \XoopsModule|null $module + * @param \XoopsModule|bool|null $module * * @return bool true if meets requirements, false if not */ - public static function checkVerPhp(\XoopsModule $module = null) + public static function checkVerPhp(\XoopsModule $module = null): bool { $moduleDirName = \basename(\dirname(__DIR__, 2)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); } @@ -86,24 +86,22 @@ public static function checkVerPhp(\XoopsModule $module = null) } /** - * - * compares current module version with latest GitHub release + * compares current module version with the latest GitHub release * @static * @param \Xmf\Module\Helper $helper * @param string|null $source * @param string|null $default * - * @return string|array info about the latest module version, if newer + * @return null|array info about the latest module version, if newer */ - - public static function checkVerModule($helper, $source = 'github', $default = 'master') + public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array { $moduleDirName = \basename(\dirname(__DIR__, 2)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $update = ''; $repository = 'XoopsModules25x/' . $moduleDirName; // $repository = 'XoopsModules25x/publisher'; //for testing only - $ret = ''; + $ret = null; $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; if ('github' === $source) { if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { @@ -114,7 +112,7 @@ public static function checkVerModule($helper, $source = 'github', $default = 'm $curlReturn = \curl_exec($curlHandle); if (false === $curlReturn) { \trigger_error(\curl_error($curlHandle)); - } elseif (false !== \strpos($curlReturn, 'Not Found')) { + } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { \trigger_error('Repository Not Found: ' . $infoReleasesUrl); } else { $file = json_decode($curlReturn, false); @@ -122,17 +120,17 @@ public static function checkVerModule($helper, $source = 'github', $default = 'm $latestVersion = $file[0]->tag_name; $prerelease = $file[0]->prerelease; if ('master' !== $latestVersionLink) { - $update = \constant('CO_' . $moduleDirNameUpper . '_' . '' . 'NEW_VERSION') . $latestVersion; + $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; } //"PHP-standardized" version - $latestVersion = mb_strtolower($latestVersion); + $latestVersion = \mb_strtolower($latestVersion); if (false !== mb_strpos($latestVersion, 'final')) { - $latestVersion = \str_replace('_', '', mb_strtolower($latestVersion)); - $latestVersion = \str_replace('final', '', mb_strtolower($latestVersion)); + $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); + $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); } $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); //"PHP-standardized" version - $moduleVersion = \str_replace(' ', '', mb_strtolower($moduleVersion)); + $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); // $moduleVersion = '1.0'; //for testing only // $moduleDirName = 'publisher'; //for testing only if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { @@ -144,6 +142,7 @@ public static function checkVerModule($helper, $source = 'github', $default = 'm \curl_close($curlHandle); } } + return $ret; } } diff --git a/class/Common/index.html b/class/Common/index.html deleted file mode 100644 index 990cbd6..0000000 --- a/class/Common/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/class/Common/index.php b/class/Common/index.php new file mode 100644 index 0000000..e5ee072 --- /dev/null +++ b/class/Common/index.php @@ -0,0 +1,2 @@ + - * @package :: xoopspoll * @since :: 1.40 **/ - - interface Constants { /**#@+ diff --git a/class/FormDateTimePicker.php b/class/FormDateTimePicker.php index ebf5e77..9fb41eb 100644 --- a/class/FormDateTimePicker.php +++ b/class/FormDateTimePicker.php @@ -1,4 +1,4 @@ - - * @credits:: {@link http://www.trentrichardson.com Trent Richardson} + * @credits:: {@link https://www.trentrichardson.com Trent Richardson} */ - - /** * Creates a text field with jquery ui calendar & time select popup */ @@ -53,20 +50,20 @@ public function __construct($caption, $name, $size, $value) * Generate the HTML to display the date/time field * @return string HTML code used to display in a form */ - public function render() + public function render(): string { static $included = false; $ele_name = $this->getName(); $ele_value = $this->getValue(true); // if (is_string($ele_value)) { - if (!\is_numeric($ele_value)) { - $display_value = $ele_value; - $ele_value = \time(); - } else { + if (\is_numeric($ele_value)) { // $display_value = ''; // $display_value = formatTimestamp($ele_value, 'm'); - $display_value = \ucfirst(\date(_MEDIUMDATESTRING, $ele_value)); + $display_value = \ucfirst(\date(_MEDIUMDATESTRING, (int)$ele_value)); + } else { + $display_value = $ele_value; + $ele_value = \time(); } if (\is_object($GLOBALS['xoTheme'])) { diff --git a/class/Helper.php b/class/Helper.php index febbaee..6c4e127 100644 --- a/class/Helper.php +++ b/class/Helper.php @@ -1,4 +1,4 @@ -dirname; } @@ -79,6 +78,7 @@ public function getHandler($name) $helper = self::getInstance(); $ret = new $class($db, $helper); $this->addLog("Getting handler '{$name}'"); + return $ret; } } diff --git a/class/Log.php b/class/Log.php index 6ea88d0..f56d758 100644 --- a/class/Log.php +++ b/class/Log.php @@ -1,4 +1,4 @@ - @@ -50,14 +47,21 @@ */ class Log extends \XoopsObject { + public int $log_id; + public int $poll_id; + public int $option_id; + public string $ip; + public int $user_id; + public int $time; + // class Log extends \XoopsObject { // var $db; /** * Constructor - * @param null $id + * @param int|null $id */ - public function __construct($id = null) + public function __construct(int $id = null) { parent::__construct(); $this->initVar('log_id', \XOBJ_DTYPE_INT, 0); @@ -66,22 +70,22 @@ public function __construct($id = null) $this->initVar('ip', \XOBJ_DTYPE_OTHER, null); $this->initVar('user_id', \XOBJ_DTYPE_INT, 0); $this->initVar('time', \XOBJ_DTYPE_INT, null); - if (!empty($id) && \is_array($id)) { - $this->assignVars($id); - } +// if (!empty($id) && \is_array($id)) { +// $this->assignVars($id); +// } } - /** * The following method is provided for backward compatibility with newbb * @param int $pid * @return mixed * @deprecated since Xoopspoll 1.40, please use LogHandler & Log */ - public static function deleteByPollId($pid) + public static function deleteByPollId(int $pid): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated since Xoopspoll 1.40, please use Log and LogHandler methods instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}"); + /** @var LogHandler $slogHandler */ $slogHandler = self::getStaticLogHandler(); $criteria = new \Criteria('poll_id', (int)$pid, '='); @@ -89,14 +93,15 @@ public static function deleteByPollId($pid) } /** - * @param $opt_id + * @param int $opt_id * @return mixed */ - public static function deleteByOptionId($opt_id) + public static function deleteByOptionId(int $opt_id): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated since Xoopspoll 1.40, please use Log and LogHandler methods instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}"); + /** @var LogHandler $slogHandler */ $slogHandler = self::getStaticLogHandler(); $criteria = new \Criteria('option_id', (int)$opt_id, '='); @@ -104,16 +109,17 @@ public static function deleteByOptionId($opt_id) } /** - * @param $pid - * @param $ip - * @param $uid + * @param int $pid + * @param string $ip + * @param int $uid * @return mixed */ - public static function hasVoted($pid, $ip, $uid) + public static function hasVoted(int $pid, string $ip, int $uid): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated since Xoopspoll 1.40, please use Log and LogHandler methods instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}"); + /** @var LogHandler $slogHandler */ $slogHandler = self::getStaticLogHandler(); return $slogHandler->hasVoted($pid, $ip, $uid); @@ -122,18 +128,17 @@ public static function hasVoted($pid, $ip, $uid) /** * @return bool */ - private static function getStaticLogHandler() + private static function getStaticLogHandler(): bool { - static $log_h; + static $logHandler; $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . ' is deprecated since Xoopspoll 1.40, please use Log and LogHandler methods instead.' . " Called from {$trace[0]['file']}line {$trace[0]['line']}"); - if (!isset($log_h)) { - $log_h = Helper::getInstance()->getHandler('Log'); + if (!isset($logHandler)) { + $logHandler = Helper::getInstance()->getHandler('Log'); } - return $log_h; + return $logHandler; } - /**#@-*/ } diff --git a/class/LogHandler.php b/class/LogHandler.php index 466f877..f6293fe 100644 --- a/class/LogHandler.php +++ b/class/LogHandler.php @@ -1,4 +1,4 @@ -deleteAll($criteria) ? true : false; + $success = $this->deleteAll($criteria); return $success; } @@ -79,23 +76,23 @@ public function deleteByOptionId($option_id) * @return bool $success * @uses CriteriaCompo */ - public function deleteByPollId($pid) + public function deleteByPollId(int $pid): bool { $criteria = new \Criteria('poll_id', (int)$pid, '='); - $success = $this->deleteAll($criteria) ? true : false; + $success = $this->deleteAll($criteria); return $success; } /** * Gets all log entries by Poll ID - * @param int $pid + * @param int $pid * @param string $sortby sort all results by this field * @param string $orderby sort order (ASC, DESC) * @return array $success * @uses CriteriaCompo */ - public function getAllByPollId($pid, $sortby = 'time', $orderby = 'ASC') + public function getAllByPollId(int $pid, string $sortby = 'time', string $orderby = 'ASC'): array { $ret = []; $criteria = new \CriteriaCompo(); @@ -113,7 +110,7 @@ public function getAllByPollId($pid, $sortby = 'time', $orderby = 'ASC') * @return int * @uses CriteriaCompo */ - public function getTotalVotesByPollId($pid) + public function getTotalVotesByPollId(int $pid): int { $criteria = new \Criteria('poll_id', (int)$pid, '='); $numVotes = $this->getCount($criteria); @@ -127,12 +124,13 @@ public function getTotalVotesByPollId($pid) * @return int * @uses CriteriaCompo */ - public function getTotalVotersByPollId($pid) + public function getTotalVotersByPollId(int $pid): int { $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('poll_id', (int)$pid, '=')); $criteria->setGroupBy('ip'); $voterGrps = $this->getCount($criteria); + //TODO Parameter '$voterGrps' type is not compatible with declaration $numVoters = \count($voterGrps); return $numVoters; @@ -144,7 +142,7 @@ public function getTotalVotersByPollId($pid) * @return int * @uses CriteriaCompo */ - public function getTotalVotesByOptionId($option_id) + public function getTotalVotesByOptionId(int $option_id): int { $criteria = new \Criteria('option_id', (int)$option_id, '='); $votes = $this->getCount($criteria); @@ -154,19 +152,19 @@ public function getTotalVotesByOptionId($option_id) /** * hasVoted indicates if user (logged in or not) has voted in a poll - * @param int $pid of the poll the check + * @param int|null $pid of the poll the check * @param string $ip the ip address for this voter * @param int $uid the XOOPS user id of this voter (0 for anon) * @return bool * @uses $_COOKIE */ - public function hasVoted($pid, $ip, $uid = 0) + public function hasVoted(?int $pid, string $ip, int $uid = 0): bool { - $uid = (int)$uid; - $pid = (int)$pid; - $voted = true; - $voted_polls = Utility::getVoteCookie(); - // $voted_polls = []; //TESTING HACK TO BYPASS COOKIES + $uid = (int)$uid; + $pid = (int)$pid; + $voted = true; + $votedPolls = Utility::getVoteCookie(); + // $votedPolls = []; //TESTING HACK TO BYPASS COOKIES $pollHandler = Helper::getInstance()->getHandler('Poll'); $pollObj = $pollHandler->get($pid); if ($pollObj) { @@ -191,7 +189,7 @@ public function hasVoted($pid, $ip, $uid = 0) $voted = $vCount > 0; } else { /* Check cookie to see if someone from this system has voted before */ - if (\array_key_exists($pid, $voted_polls) && ((int)$voted_polls[$pid] >= $pollStarttime)) { + if (\array_key_exists($pid, $votedPolls) && ((int)$votedPolls[$pid] >= $pollStarttime)) { $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('poll_id', $pid, '=')); $criteria->add(new \Criteria('time', (int)$pollStarttime, '>=')); diff --git a/class/Option.php b/class/Option.php index 8ccf45e..fadf63d 100644 --- a/class/Option.php +++ b/class/Option.php @@ -1,4 +1,4 @@ -optHandler = $this->getStaticOptHandler(); - if (!empty($id)) { + if (null !== $id) { if (\is_array($id)) { $this->option = $this->optHandler->create(); $this->option->assignVars($id); @@ -92,18 +98,17 @@ public function __construct($id = null) } } - /**#@+ * @deprecated since Xoopspoll 1.40, please @see OptionHandler & @see Option */ + /** - * * Stores object into the database - * @uses XoopsPersistableObjectHandler::insert * @return mixed + * @uses XoopsPersistableObjectHandler::insert * @deprecated since Xoopspoll 1.40, please @see XoopspollOptionHandler & @see XoopspollOption */ - public function store() + public function store(): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use Poll and PollHandler classes instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); @@ -113,49 +118,46 @@ public function store() /** * Delete all the poll options for a specific poll - * @uses XoopsPersistableObjectHandler::deleteAll - * @param int $pid is used to delete all options by this id + * @param int $pid is used to delete all options by this id * @return mixed results of deleting objects from database * @uses XoopsPersistableObjectHandler::deleteAll */ - public function deleteByPollId($pid) + public function deleteByPollId(int $pid): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); - $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::' . __METHOD__ . ' instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); - $criteria = new \Criteria('poll_id', (int)$pid, '='); + $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::deleteAll instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); + $criteria = new Criteria('poll_id', (int)$pid, '='); return $this->optHandler->deleteAll($criteria); } /** * Get all options for a particular poll - * @uses XoopsPersistableObjectHandler::getAll - * @param unknown $pid + * @param int $pid * @return mixed results of getting objects from database * @uses XoopsPersistableObjectHandler::getAll */ - public function getAllByPollId($pid) + public function getAllByPollId(int $pid): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); - $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::' . __METHOD__ . ' instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); - $criteria = new \Criteria('poll_id', (int)$pid, '='); + $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::getAll instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); + $criteria = new Criteria('poll_id', (int)$pid, '='); return $this->optHandler->getAll($criteria); } /** * Reset the poll's options vote count - * @param unknown_type $pid - * @uses XoopsPersistableObjectHandler::updateAll + * @param int $pid * @return mixed results of the object(s) update * @uses XoopsPersistableObjectHandler::updateAll */ - public function resetCountByPollId($pid) + public function resetCountByPollId(int $pid): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); - $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::' . __METHOD__ . ' instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); + $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::updateAll instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); $soptHandler = $this->getStaticOptHandler(); - $criteria = new \Criteria('poll_id', (int)$pid, '='); + $criteria = new Criteria('poll_id', (int)$pid, '='); return $soptHandler->updateAll('option_count', 0, $criteria); } @@ -165,16 +167,15 @@ public function resetCountByPollId($pid) * @return mixed handler object returned on success, false on failure * @uses xoops_getModuleHandler */ - private function getStaticOptHandler() + private function getStaticOptHandler(): mixed { static $optionHandler; if (!isset($optionHandler)) { $optionHandler = Helper::getInstance()->getHandler('Option'); - } - - return $optionHandler; } + return $optionHandler; + } /**#@-*/ } diff --git a/class/OptionHandler.php b/class/OptionHandler.php index 1b82307..de002d2 100644 --- a/class/OptionHandler.php +++ b/class/OptionHandler.php @@ -1,4 +1,4 @@ -helper = Helper::getInstance(); - } else { - $this->helper = $helper; - } + $this->helper = $helper ?? Helper::getInstance(); parent::__construct($db, 'xoopspoll_option', Option::class, 'option_id', 'option_text'); } /** - * Update the option vote count for a Option Object + * Update the option vote count for an Option Object * @param mixed $optionObj is an option object to update * @return mixed results @see XoopsPersistibleObjectHandler * @uses xoops_getModuleHandler * @uses XoopsPersistableObjectHandler::insert */ - public function updateCount($optionObj) + public function updateCount(mixed $optionObj): mixed { $status = false; static $logHandler; if ($optionObj instanceof Option) { $option_id = $optionObj->getVar('option_id'); if (!isset($logHandler)) { - $logHandler = $this->helper::getInstance()->getHandler('Log'); + $logHandler = $this->helper->getHandler('Log'); } $votes = $logHandler->getTotalVotesByOptionId($option_id); $optionObj->setVar('option_count', $votes); @@ -95,14 +90,14 @@ public function updateCount($optionObj) /** * Gets all options for poll ID * - * @param int $pid + * @param int $pid * @param string $sortby * @param string $orderby * @return array an array of Option objects * @uses CriteriaCompo * @uses XoopsPersistableObjectHandler::deleteAll */ - public function getAllByPollId($pid = 0, $sortby = 'option_id', $orderby = 'ASC') + public function getAllByPollId(int $pid = 0, string $sortby = 'option_id', string $orderby = 'ASC'): array { // $criteria = new \CriteriaCompo(); $criteria = new \Criteria('poll_id', (int)$pid, '='); @@ -128,7 +123,7 @@ public function getAllByPollId($pid = 0, $sortby = 'option_id', $orderby = 'ASC' * @uses XoopsPersistableObjectHandler::deleteAll * @uses Criteria */ - public function deleteByPollId($pid = 0) + public function deleteByPollId(int $pid = 0): bool { $success = $this->deleteAll(new \Criteria('poll_id', (int)$pid, '=')); @@ -143,7 +138,7 @@ public function deleteByPollId($pid = 0) * @uses XoopsPersistableObjectHandler::updateAll * @uses Criteria */ - public function resetCountByPollId($pid = 0) + public function resetCountByPollId(int $pid = 0): bool { $success = $this->updateAll('option_count', 0, new \Criteria('poll_id', (int)$pid, '=')); @@ -151,15 +146,16 @@ public function resetCountByPollId($pid = 0) } /** - * Generates an html select box with options - * @param mixed $pid the select box is created for this poll id - * @return string html select box + * Generates a HTML select box with options + * @param int $pid the select box is created for this poll id + * @return \XoopsFormElementTray html select box */ - public function renderOptionFormTray($pid = 0) + public function renderOptionFormTray(int $pid = 0): \XoopsFormElementTray { \xoops_load('xoopsformloader'); $pid = (int)$pid; $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/xoopspoll/assets/images/colorbars/')); + $optionObjs = []; /** * get all the options for this poll & add some blank options to allow adding more diff --git a/class/Plugin/UserlogPlugin.php b/class/Plugin/UserlogPlugin.php index f36a690..efceb82 100644 --- a/class/Plugin/UserlogPlugin.php +++ b/class/Plugin/UserlogPlugin.php @@ -1,4 +1,4 @@ - @@ -26,9 +25,8 @@ use Xmf\Request; use XoopsModules\Userlog; - /** +/** * Class UserlogPlugin - * @package XoopsModules\Xoopspoll\Plugin */ class UserlogPlugin extends Userlog\Plugin\PluginAbstract implements Userlog\Plugin\PluginInterface { @@ -44,7 +42,7 @@ class UserlogPlugin extends Userlog\Plugin\PluginAbstract implements Userlog\Plu * * @return array|bool $item["item_name"] name of the item, $item["item_id"] id of the item */ - public function item($subscribe_from) + public function item(string $subscribe_from) { $poll_id = Request::getInt('poll_id', 0); switch ($subscribe_from) { diff --git a/class/Plugin/index.php b/class/Plugin/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/class/Plugin/index.php @@ -0,0 +1,3 @@ + */ +\xoops_loadLanguage('admin', \basename(\dirname(__DIR__))); - - /** +/** * Class Poll - * @package XoopsModules\Xoopspoll */ class Poll extends \XoopsObject { + private int $poll_id; + private string $question; + private string $description; + private int $user_id; + private int $start_time; + private int $end_time; + private int $votes; + private int $voters; + private int $display; + private int $visibility; + private int $anonymous; + private int $weight; + private int $multiple; + private int $multilimit; + private int $mail_status; + private int $mail_voter; + /** * Poll::__construct() * @@ -38,13 +53,13 @@ public function __construct($id = null) { parent::__construct(); // $timestamp = xoops_getUserTimestamp(time()); - $current_timestamp = \time(); + $currentTimestamp = \time(); $this->initVar('poll_id', \XOBJ_DTYPE_INT, null, false); $this->initVar('question', \XOBJ_DTYPE_TXTBOX, null, true, 255); $this->initVar('description', \XOBJ_DTYPE_TXTAREA, null, false); $this->initVar('user_id', \XOBJ_DTYPE_INT, null, false); - $this->initVar('start_time', \XOBJ_DTYPE_INT, $current_timestamp, false); - $this->initVar('end_time', \XOBJ_DTYPE_INT, $current_timestamp + Constants::DEFAULT_POLL_DURATION, true); + $this->initVar('start_time', \XOBJ_DTYPE_INT, $currentTimestamp, false); + $this->initVar('end_time', \XOBJ_DTYPE_INT, $currentTimestamp + Constants::DEFAULT_POLL_DURATION, true); $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false); $this->initVar('voters', \XOBJ_DTYPE_INT, 0, false); $this->initVar('display', \XOBJ_DTYPE_INT, Constants::DISPLAY_POLL_IN_BLOCK, false); @@ -60,12 +75,12 @@ public function __construct($id = null) * {@internal This code added to support previous versions of newbb/xForum} */ if (!empty($id)) { - $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); - $err_msg = __CLASS__ . " instantiation with 'id' set is deprecated since Xoopspoll 1.40, please use PollHandler instead." . " Called from {$trace[0]['file']}line {$trace[0]['line']}"; + $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); + $errorMsg = __CLASS__ . " instantiation with 'id' set is deprecated since Xoopspoll 1.40, please use PollHandler instead." . " Called from {$trace[0]['file']}line {$trace[0]['line']}"; if (isset($GLOBALS['xoopsLogger'])) { - $GLOBALS['xoopsLogger']->addDeprecated($err_msg); + $GLOBALS['xoopsLogger']->addDeprecated($errorMsg); } else { - \trigger_error($err_msg, \E_USER_WARNING); + \trigger_error($errorMsg, \E_USER_WARNING); } if (\is_array($id)) { @@ -85,16 +100,15 @@ public function __construct($id = null) public function __toString() { $ret = $this->getVar('question'); - return $ret; + + return (string)$ret; } /** * Find out if poll has expired - * @access public - * @return bool * @uses Poll::getVar() */ - public function hasExpired() + public function hasExpired(): bool { $ret = true; if ($this->getVar('end_time') > \time()) { @@ -106,12 +120,10 @@ public function hasExpired() /** * Determine if user is allowed to vote in this poll - * @return bool * @uses Poll::getVar() - * @access public * @uses XoopsUser */ - public function isAllowedToVote() + public function isAllowedToVote(): bool { $ret = false; if ((Constants::ANONYMOUS_VOTING_ALLOWED === $this->getVar('anonymous')) @@ -125,10 +137,9 @@ public function isAllowedToVote() } /** - * @access public - * @param int $optionId - * @param string $ip ip address of voter - * @param $time + * @param int $optionId + * @param string $ip ip address of voter + * @param int $time * @return bool true vote entered, false voting failed * @uses xoops_getModuleHandler() * @uses CriteriaCompo() @@ -136,7 +147,7 @@ public function isAllowedToVote() * @uses LogHandler * @internal param int $uid */ - public function vote($optionId, $ip, $time) + public function vote(int $optionId, string $ip, int $time): bool { if (!empty($optionId) && $this->isAllowedToVote()) { $voteTime = empty($time) ? \time() : (int)$time; @@ -184,15 +195,15 @@ public function vote($optionId, $ip, $time) /** * Gets number of comments for this poll - * @access public * @param int poll_id * @return int count of comments for this poll_id */ - public function getComments() + public function getComments(): int { $moduleHandler = \xoops_getHandler('module'); $pollModule = $moduleHandler->getByDirname('xoopspoll'); + /** @var \XoopsCommentHandler $commentHandler */ $commentHandler = \xoops_getHandler('comment'); $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_itemid', $this->getVar('poll_id'), '=')); @@ -207,16 +218,16 @@ public function getComments() * display the poll form * @param string $rtnPage where to send the form result * @param string $rtnMethod return method get|post - * @param array $addHidden + * @param array $addHidden */ - public function renderForm($rtnPage, $rtnMethod = 'post', $addHidden = []) + public function renderForm(string $rtnPage, string $rtnMethod = 'post', array $addHidden = []) { \xoops_load('xoopsformloader'); $myts = \MyTextSanitizer::getInstance(); - $rtnMethod = mb_strtolower($rtnMethod); + $rtnMethod = \mb_strtolower($rtnMethod); // force form to use xoopsSecurity if it's a 'post' form - $rtnSecurity = 'post' === mb_strtolower($rtnMethod); + $rtnSecurity = 'post' === \mb_strtolower($rtnMethod); // set form titles, etc. depending on if it's a new object or not if ($this->isNew()) { @@ -237,11 +248,11 @@ public function renderForm($rtnPage, $rtnMethod = 'post', $addHidden = []) $descTarea = new \XoopsFormTextarea(_AM_XOOPSPOLL_POLLDESC, "description", $this->getVar('description', 'E')); $pollForm->addElement($descTarea); */ + /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = \xoops_getHandler('module'); $pollModule = $moduleHandler->getByDirname('xoopspoll'); - /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = \xoops_getHandler('module'); + /** @var \XoopsConfigHandler $configHandler */ $configHandler = \xoops_getHandler('config'); // $xp_module = $moduleHandler->getByDirname("xoopspoll"); // $module_id = $xp_module->getVar("mid"); @@ -259,8 +270,8 @@ public function renderForm($rtnPage, $rtnMethod = 'post', $addHidden = []) 'width' => '100%', 'height' => '350px', 'name' => 'description', - // 'value' => $myts->stripSlashesGPC($this->getVar('description')) - 'value' => $myts->htmlSpecialChars($this->getVar('description')), + // 'value' => ($this->getVar('description')) + 'value' => \htmlspecialchars($this->getVar('description'), \ENT_QUOTES | \ENT_HTML5), ]; $desc_text = new \XoopsFormEditor(\_AM_XOOPSPOLL_POLLDESC, 'description', $editorConfigs); $pollForm->addElement($desc_text); @@ -271,15 +282,13 @@ public function renderForm($rtnPage, $rtnMethod = 'post', $addHidden = []) $timeTray = new \XoopsFormElementTray(\_AM_XOOPSPOLL_POLL_TIMES, '  ', 'time_tray'); $xuCurrentTimestamp = \xoops_getUserTimestamp(\time()); - $xuCurrentFormatted = \ucfirst(\date(_MEDIUMDATESTRING, $xuCurrentTimestamp)); + $xuCurrentFormatted = \ucfirst(\date(_MEDIUMDATESTRING, (int)$xuCurrentTimestamp)); $xuStartTimestamp = \xoops_getUserTimestamp($this->getVar('start_time')); $xuEndTimestamp = \xoops_getUserTimestamp($this->getVar('end_time')); /* display start/end time fields on form */ $startTimeText = new FormDateTimePicker("
    " . \_AM_XOOPSPOLL_START_TIME . '
    ' . "" . \_AM_XOOPSPOLL_FORMAT . '
    ' . \sprintf(\_AM_XOOPSPOLL_CURRENTTIME, $xuCurrentFormatted) . '
    ', 'xu_start_time', 20, $xuStartTimestamp); - if (!$this->hasExpired()) { - $endTimeText = new FormDateTimePicker("
    " . \_AM_XOOPSPOLL_EXPIRATION . '
    ', 'xu_end_time', 20, $xuEndTimestamp); - } else { + if ($this->hasExpired()) { /* $extra = ""; foreach ($addHidden as $key=>$value) { @@ -295,10 +304,12 @@ public function renderForm($rtnPage, $rtnMethod = 'post', $addHidden = []) */ $extra = \is_array($addHidden) ? $addHidden : []; $extra = \array_merge($extra, ['op' => 'restart', 'poll_id' => $this->getVar('poll_id')]); - $query = \http_build_query($extra); + $query = \http_build_query($extra, '', '&'); $query = \htmlentities($query, \ENT_QUOTES); $xuEndFormattedTime = \ucfirst(\date(_MEDIUMDATESTRING, $xuEndTimestamp)); $endTimeText = new \XoopsFormLabel("
    " . \_AM_XOOPSPOLL_EXPIRATION, \sprintf(\_AM_XOOPSPOLL_EXPIREDAT, $xuEndFormattedTime) . "
    " . \_AM_XOOPSPOLL_RESTART . '
    '); + } else { + $endTimeText = new FormDateTimePicker("
    " . \_AM_XOOPSPOLL_EXPIRATION . '
    ', 'xu_end_time', 20, $xuEndTimestamp); } $timeTray->addElement($startTimeText); @@ -353,10 +364,11 @@ public function renderForm($rtnPage, $rtnMethod = 'post', $addHidden = []) /** * Method determines if current user can view the results of this poll - * @return mixed visibility of this poll's results (true if visible, msg if not) + * @return bool|string visibility of this poll's results (true if visible, msg if not) */ public function isResultVisible() { + $visibleMsg = ''; \xoops_loadLanguage('main', 'xoopspoll'); switch ($this->getVar('visibility')) { case Constants::HIDE_ALWAYS: // always hide the results @@ -365,11 +377,11 @@ public function isResultVisible() $visibleMsg = \_MD_XOOPSPOLL_HIDE_ALWAYS_MSG; break; case Constants::HIDE_END: // hide the results until the poll ends - if (!$this->hasExpired()) { + if ($this->hasExpired()) { + $isVisible = true; + } else { $visibleMsg = \_MD_XOOPSPOLL_HIDE_END_MSG; $isVisible = false; - } else { - $isVisible = true; } break; case Constants::HIDE_VOTED: // hide the results until user votes @@ -395,10 +407,10 @@ public function isResultVisible() /** * Send copy of vote to the user at time of vote (if selected) * - * @param null $user the Xoops user object for this user + * @param \XoopsUser|null $user the Xoops user object for this user * @return bool send status */ - public function notifyVoter($user = null) + public function notifyVoter(\XoopsUser $user = null): bool { if (($user instanceof \XoopsUser) && (Constants::MAIL_POLL_TO_VOTER === $this->getVar('mail_voter'))) { \xoops_loadLanguage('main', 'xoopspoll'); @@ -423,7 +435,7 @@ public function notifyVoter($user = null) $xoopsMailer->assign('POLL_QUESTION', $this->getVar('question')); $xuEndTimestamp = \xoops_getUserTimestamp($this->getVar('end_time')); - $xuEndFormattedTime = \ucfirst(\date(_MEDIUMDATESTRING, $xuEndTimestamp)); + $xuEndFormattedTime = \ucfirst(\date(_MEDIUMDATESTRING, (int)$xuEndTimestamp)); // on the outside chance this expired right after the user voted. if ($this->hasExpired()) { $xoopsMailer->assign('POLL_END', \sprintf(\_MD_XOOPSPOLL_ENDED_AT, $xuEndFormattedTime)); @@ -468,16 +480,12 @@ public function notifyVoter($user = null) return $status; } - /**#@+ - * The following method is provided for backward compatibility with newbb/xforum - * @deprecated since Xoopspoll 1.40, please use PollHandler & Poll - */ - /** + * The following method is provided for backward compatibility with newbb/xforum * deletes the object from the database * @return mixed results of deleting poll from db - */ - public function delete() + * @deprecated since Xoopspoll 1.40, please use PollHandler & Poll + */ public function delete(): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::' . __METHOD__ . ' instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); @@ -489,6 +497,7 @@ public function delete() /** * update the vote counter for this poll * @returns bool results of update counter + * @deprecated since Xoopspoll 1.40, please use PollHandler & Poll */ public function updateCount() { @@ -502,8 +511,9 @@ public function updateCount() /** * inserts the poll object into the database * @return mixed results of inserting poll into db + * @deprecated since Xoopspoll 1.40, please use PollHandler & Poll */ - public function store() + public function store(): mixed { $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1); $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::insert() instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}"); @@ -513,7 +523,7 @@ public function store() } /** - * Setup a static Poll Handler for use by class methods + * Set up a static Poll Handler for use by class methods */ private function getStaticPollHandler() { @@ -527,6 +537,5 @@ private function getStaticPollHandler() return $pH; } - /**#@-*/ } diff --git a/class/PollHandler.php b/class/PollHandler.php index 2390637..fb72f1a 100644 --- a/class/PollHandler.php +++ b/class/PollHandler.php @@ -1,6 +1,4 @@ - */ - - /** +/** * Class PollHandler */ class PollHandler extends \XoopsPersistableObjectHandler @@ -33,31 +29,25 @@ class PollHandler extends \XoopsPersistableObjectHandler /** * @var \XoopsModules\Xoopspoll\Helper */ - protected $helper; + protected Helper $helper; /** * PollHandler::__construct() * - * @param null|\XoopsDatabase $db * @param \XoopsModules\Xoopspoll\Helper|null $helper */ public function __construct(\XoopsDatabase $db = null, Helper $helper = null) { - if (null === $helper) { - $this->helper = Helper::getInstance(); - } else { - $this->helper = $helper; - } + $this->helper = $helper ?? Helper::getInstance(); parent::__construct($db, 'xoopspoll_desc', Poll::class, 'poll_id', 'question'); } /** * Update the Vote count from the log and polls - * @access public * @param \XoopsObject $pollObj - * @return bool $success + * @return int|false object ID or false */ - public function updateCount($pollObj) + public function updateCount(\XoopsObject $pollObj) { $success = false; if ($pollObj instanceof Poll) { @@ -76,10 +66,10 @@ public function updateCount($pollObj) /** * Mail the results of poll when expired - * @param mixed $pollObj + * @param mixed|null $pollObj * @return array true|false indicating sendmail status */ - public function mailResults($pollObj = null) + public function mailResults(mixed $pollObj = null): array { $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('end_time', \time(), '<')); // expired polls diff --git a/class/PollUtility.php b/class/PollUtility.php index acba300..d2d5f43 100644 --- a/class/PollUtility.php +++ b/class/PollUtility.php @@ -1,4 +1,4 @@ -getByDirname('xoopspoll'); + /** @var \XoopsConfigHandler $cHandler */ $cHandler = \xoops_getHandler('config'); $mConfig = $cHandler->getConfigsByCat(0, $mod->getVar('mid')); } @@ -80,7 +79,7 @@ public static function commentMode() * Creates a visibility array from module default values * @return array visibility options available for a poll */ - public static function getVisibilityArray() + public static function getVisibilityArray(): array { /** * {@internal Do NOT add/delete from $visOptions after the module has been installed} @@ -103,13 +102,13 @@ public static function getVisibilityArray() * Retrieves vote cookie from client system * The cookie name is based on the module directory. If module is * installed in default location then cookie name is 'voted_polls' - * for backward compatibility. Otherwise cookie is named + * for backward compatibility. Otherwise, cookie is named * '_voted_polls' to allow for module to be cloned using * smartClone module. - * @param null $cookieBaseName + * @param string|null $cookieBaseName * @return array contains cookie for polls, empty array if not found */ - public static function getVoteCookie($cookieBaseName = null) + public static function getVoteCookie(string $cookieBaseName = null): array { // $cookieBaseName = null === $cookieBaseName ? 'voted_polls': $cookieBaseName; if (null === $cookieBaseName) { @@ -129,16 +128,16 @@ public static function getVoteCookie($cookieBaseName = null) * Sets vote cookie on client system * The cookie name is based on the module directory. If module is * installed in default location then cookie name is 'voted_polls' - * for backward compatibility. Otherwise cookie is named + * for backward compatibility. Otherwise, cookie is named * '_voted_polls' to allow for module to be cloned using * smartClone module. - * @param int|string $index array index to set in cookie - * @param string $value data to store in cookie - * @param int $expires time when cookie expires - * @param string $cookieBaseName name of cookie (without directory prefix) + * @param bool|int|string $index array index to set in cookie + * @param string $value data to store in cookie + * @param int $expires time when cookie expires + * @param string $cookieBaseName name of cookie (without directory prefix) * @return bool success in setting cookie */ - public static function setVoteCookie($index, $value, $expires = 0, $cookieBaseName = 'voted_polls') + public static function setVoteCookie($index, string $value, int $expires = 0, string $cookieBaseName = 'voted_polls'): bool { $pollDir = \basename(\dirname(__DIR__)); $success = false; @@ -176,18 +175,18 @@ public static function setVoteCookie($index, $value, $expires = 0, $cookieBaseNa * Sets vote cookie on client system * The cookie name is based on the module directory. If module is * installed in default location then cookie name is 'voted_polls' - * for backward compatibility. Otherwise cookie is named + * for backward compatibility. Otherwise, cookie is named * '_voted_polls' to allow for module to be cloned using * smartClone module. * @param \XoopsDatabase|null $db - * @param $tablename + * @param string $tablename * @return bool success in setting cookie * @internal param int|string $index array index to set in cookie * @internal param unknown_type $value data to store in cookie * @internal param int $expires time when cookie expires * @internal param string $cookieBaseName name of cookie (without directory prefix) */ - public static function dbTableExists(\XoopsDatabase $db, $tablename) + public static function dbTableExists(\XoopsDatabase $db, string $tablename): bool { $tablename = \addslashes($tablename); $mytable = $db->prefix((string)$tablename); diff --git a/class/Renderer.php b/class/Renderer.php index dd3b9ef..0af4f01 100644 --- a/class/Renderer.php +++ b/class/Renderer.php @@ -1,4 +1,4 @@ -loadLanguage('main'); - /** * Class Renderer */ class Renderer { - // XoopsPoll class object - protected $pollObj; - protected $pollHandler; - protected $optionHandler; - protected $logHandler; - protected $helper; - + // Poll class object + protected Poll $pollObj; + protected PollHandler $pollHandler; + protected OptionHandler $optionHandler; + protected LogHandler $logHandler; + protected Helper $helper; // constructor(s) /** - * @param null $poll - * @param null $helper + * @param Poll|null $poll + * @param Helper|null $helper */ - public function __construct($poll = null, $helper = null) + public function __construct(Poll $poll = null, Helper $helper = null) { - if (null === $helper) { - $this->helper = Helper::getInstance(); - } else { - $this->helper = $helper; - } + $this->helper = $helper ?? Helper::getInstance(); // setup handlers - $this->pollHandler = $this->helper->getHandler('Poll'); - $this->optionHandler = $this->helper->getHandler('Option'); - $this->logHandler = $this->helper->getHandler('Log'); + $this->pollHandler = $this->helper->getHandler('Poll'); + $this->optionHandler = $this->helper->getHandler('Option'); + $this->logHandler = $this->helper->getHandler('Log'); if ($poll instanceof Poll) { $this->pollObj = $poll; @@ -83,23 +79,22 @@ public function __construct($poll = null, $helper = null) /** * create html form to display poll - * @access public * @return string html form for display */ - public function renderForm() + public function renderForm(): string { $myTpl = new \XoopsTpl(); $this->assignForm($myTpl); // get the poll information - return $myTpl->fetch($GLOBALS['xoops']->path('modules/xoopspoll/templates/xoopspoll_view.tpl')); + // return $myTpl->fetch($GLOBALS['xoops']->path('modules/xoopspoll/templates/xoopspoll_view.tpl')); + return $myTpl->fetch($this->helper->path('templates/xoopspoll_view.tpl')); } /** * assigns form values to template for display - * @access public - * @var \XoopsTpl $tpl + * @var \XoopsTpl */ - public function assignForm(\XoopsTpl $tpl) + public function assignForm(\XoopsTpl $tpl): void { $myts = \MyTextSanitizer::getInstance(); $optionObjs = $this->optionHandler->getAllByPollId($this->pollObj->getVar('poll_id')); @@ -122,7 +117,7 @@ public function assignForm(\XoopsTpl $tpl) 'text' => $optionObj->getVar('option_text'), ]; } - $uid = (isset($GLOBALS['xoopsUser']) + $uid = (isset($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; $can_vote = false; if ($this->pollObj->isAllowedToVote() @@ -131,54 +126,52 @@ public function assignForm(\XoopsTpl $tpl) } /* $tpl->assign('poll', array( - 'question' => $myts->htmlSpecialChars($this->pollObj->getVar('question')), + 'question' => htmlspecialchars($this->pollObj->getVar('question')), 'pollId' => $this->pollObj->getVar('poll_id'), 'viewresults' => $GLOBALS['xoops']->url("modules/xoopspoll/pollresults.php") . "?poll_id=" . $this->pollObj->getVar('poll_id'), 'options' => $options, 'description' => $myts->displayTarea($myts->undoHtmlSpecialChars($this->pollObj->getVar('description')), 1)) ); */ - $tpl->assign( - [ - 'poll' => [ - 'question' => $myts->htmlSpecialChars($this->pollObj->getVar('question')), - 'pollId' => $this->pollObj->getVar('poll_id'), - 'viewresults' => $GLOBALS['xoops']->url('modules/xoopspoll/pollresults.php') . '?poll_id=' . $this->pollObj->getVar('poll_id'), - 'options' => $options ?? '', - 'description' => $myts->displayTarea($myts->undoHtmlSpecialChars($this->pollObj->getVar('description')), 1), - ], + $tpl->assign([ + 'poll' => [ + 'question' => \htmlspecialchars($this->pollObj->getVar('question'), \ENT_QUOTES | \ENT_HTML5), + 'pollId' => $this->pollObj->getVar('poll_id'), + 'viewresults' => $GLOBALS['xoops']->url('modules/xoopspoll/pollresults.php') . '?poll_id=' . $this->pollObj->getVar('poll_id'), + 'options' => $options ?? [], + 'description' => $myts->displayTarea($myts->undoHtmlSpecialChars($this->pollObj->getVar('description')), 1), + ], 'can_vote' => $can_vote, 'action' => $GLOBALS['xoops']->url('modules/xoopspoll/index.php'), - 'lang_vote' => \_MD_XOOPSPOLL_VOTE, - 'lang_results' => \_MD_XOOPSPOLL_RESULTS, - ] - ); + 'lang_vote' => \_MD_XOOPSPOLL_VOTE, + 'lang_results' => \_MD_XOOPSPOLL_RESULTS, + ]); } /** * display html results to screen (echo) - * @access public */ public function renderResults() { $myTpl = new \XoopsTpl(); $this->assignResults($myTpl); // get the poll information - return $myTpl->fetch($GLOBALS['xoops']->path('modules/xoopspoll/templates/xoopspoll_results_renderer.tpl')); + // return $myTpl->fetch($GLOBALS['xoops']->path('modules/xoopspoll/templates/xoopspoll_results_renderer.tpl')); + return $myTpl->fetch($this->helper->path('templates/xoopspoll_results_renderer.tpl')); } /** * assigns form results to template - * @access public * @var \XoopsTpl tpl */ - public function assignResults(\XoopsTpl $tpl) + public function assignResults(\XoopsTpl $tpl): void { $myts = \MyTextSanitizer::getInstance(); $xuEndTimestamp = \xoops_getUserTimestamp($this->pollObj->getVar('end_time')); - $xuEndFormatted = \ucfirst(\date(_MEDIUMDATESTRING, $xuEndTimestamp)); + $xuEndFormatted = \ucfirst(\date(_MEDIUMDATESTRING, (int)$xuEndTimestamp)); $xuStartTimestamp = \xoops_getUserTimestamp($this->pollObj->getVar('start_time')); - $xuStartFormatted = \ucfirst(\date(_MEDIUMDATESTRING, $xuStartTimestamp)); + $xuStartFormatted = \ucfirst(\date(_MEDIUMDATESTRING, (int)$xuStartTimestamp)); + $options = []; // $logHandler = $this->helper->getHandler('Log'); $criteria = new \CriteriaCompo(); @@ -200,10 +193,11 @@ public function assignResults(\XoopsTpl $tpl) /* setup module config handler - required since this is called by newbb too */ /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = \xoops_getHandler('module'); + /** @var \XoopsConfigHandler $configHandler */ $configHandler = \xoops_getHandler('config'); - $xp_module = $moduleHandler->getByDirname('xoopspoll'); - $module_id = $xp_module->getVar('mid'); - $xp_config = $configHandler->getConfigsByCat(0, $module_id); + $xp_module = $moduleHandler->getByDirname('xoopspoll'); + $module_id = $xp_module->getVar('mid'); + $xp_config = $configHandler->getConfigsByCat(0, $module_id); if ($xp_config['disp_vote_nums']) { $options[$i]['percent'] = \sprintf(' %01.1f%% (%d)', $percent, $optionVars['option_count']); @@ -212,13 +206,13 @@ public function assignResults(\XoopsTpl $tpl) } $options[$i]['text'] = $optionVars['option_text']; $options[$i]['total'] = $optionVars['option_count']; - $options[$i]['value'] = (int) $percent; + $options[$i]['value'] = (int)$percent; ++$i; unset($optionVars); } - $uid = (isset($GLOBALS['xoopsUser']) + $uid = (isset($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; - $vote = null; + $vote = null; if (!$this->pollObj->hasExpired() && $this->pollObj->isAllowedToVote() && !$this->logHandler->hasVoted($this->pollObj->getVar('poll_id'), \xoops_getenv('REMOTE_ADDR'), $uid)) { $vote = "url('modules/xoopspoll/index.php') . '?poll_id=' . $this->pollObj->getVar('poll_id') . "'>" . \_MD_XOOPSPOLL_VOTE_NOW . ''; @@ -230,18 +224,15 @@ public function assignResults(\XoopsTpl $tpl) $totalVotes = $totalVoters = ''; } - $tpl->assign( - 'poll', - [ - 'question' => $myts->htmlSpecialChars($this->pollObj->getVar('question')), + $tpl->assign('poll', [ + 'question' => \htmlspecialchars($this->pollObj->getVar('question'), \ENT_QUOTES | \ENT_HTML5), 'end_text' => $xuEndFormatted, 'start_text' => $xuStartFormatted, 'totalVotes' => $totalVotes, 'totalVoters' => $totalVoters, 'vote' => $vote, 'options' => $options, - 'description' => $this->pollObj->getVar('description'), //allow html - ] - ); + 'description' => $this->pollObj->getVar('description'), //allow html + ]); } } diff --git a/class/Utility.php b/class/Utility.php index b530b53..87cdc58 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -1,4 +1,4 @@ -getByDirname('xoopspoll'); + /** @var \XoopsConfigHandler $cHandler */ $cHandler = \xoops_getHandler('config'); $mConfig = &$cHandler->getConfigsByCat(0, $mod->getVar('mid')); } @@ -57,7 +57,7 @@ public static function commentMode() * Creates a visibility array from module default values * @return array visibility options available for a poll */ - public static function getVisibilityArray() + public static function getVisibilityArray(): array { /** * {@internal Do NOT add/delete from $visOptions after the module has been installed} @@ -80,13 +80,13 @@ public static function getVisibilityArray() * Retrieves vote cookie from client system * The cookie name is based on the module directory. If module is * installed in default location then cookie name is 'voted_polls' - * for backward compatibility. Otherwise cookie is named + * for backward compatibility. Otherwise , cookie is named * '_voted_polls' to allow for module to be cloned using * smartClone module. * @param string $cookieBaseName * @return array contains cookie for polls, empty array if not found */ - public static function getVoteCookie($cookieBaseName = 'voted_polls') + public static function getVoteCookie(string $cookieBaseName = 'voted_polls'): array { $pollDir = \basename(\dirname(__DIR__)); if ('xoopspoll' === $pollDir) { @@ -102,16 +102,16 @@ public static function getVoteCookie($cookieBaseName = 'voted_polls') * Sets vote cookie on client system * The cookie name is based on the module directory. If module is * installed in default location then cookie name is 'voted_polls' - * for backward compatibility. Otherwise cookie is named + * for backward compatibility. Otherwise , cookie is named * '_voted_polls' to allow for module to be cloned using * smartClone module. - * @param int|string $index array index to set in cookie - * @param string $value data to store in cookie - * @param int $expires time when cookie expires - * @param string $cookieBaseName name of cookie (without directory prefix) + * @param bool|int|string $index array index to set in cookie + * @param string $value data to store in cookie + * @param int $expires time when cookie expires + * @param string $cookieBaseName name of cookie (without directory prefix) * @return bool success in setting cookie */ - public static function setVoteCookie($index, $value, $expires = 0, $cookieBaseName = 'voted_polls') + public static function setVoteCookie($index, string $value, int $expires = 0, string $cookieBaseName = 'voted_polls'): bool { $pollDir = \basename(\dirname(__DIR__)); $success = false; @@ -149,18 +149,18 @@ public static function setVoteCookie($index, $value, $expires = 0, $cookieBaseNa * Sets vote cookie on client system * The cookie name is based on the module directory. If module is * installed in default location then cookie name is 'voted_polls' - * for backward compatibility. Otherwise cookie is named + * for backward compatibility. Otherwise , cookie is named * '_voted_polls' to allow for module to be cloned using * smartClone module. * @param \XoopsDatabase|null $db - * @param $tablename + * @param string $tablename * @return bool success in setting cookie * @internal param int|string $index array index to set in cookie * @internal param unknown_type $value data to store in cookie * @internal param int $expires time when cookie expires * @internal param string $cookieBaseName name of cookie (without directory prefix) */ - public static function dbTableExists(\XoopsDatabase $db, $tablename) + public static function dbTableExists(\XoopsDatabase $db, string $tablename): bool { $tablename = \addslashes($tablename); $mytable = $db->prefix((string)$tablename); diff --git a/class/index.html b/class/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/class/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/class/index.php b/class/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/class/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/class/plugin/userlog.php b/class/plugin/userlog.php index b2c0500..d824c3f 100644 --- a/class/plugin/userlog.php +++ b/class/plugin/userlog.php @@ -1,4 +1,4 @@ - */ // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); -class XoopspollUserlogPlugin extends \Userlog_Module_Plugin_Abstract implements \UserlogPluginInterface +class Userlog extends \Userlog_Module_Plugin_Abstract implements \UserlogPluginInterface { /** * @param string $subscribe_from Name of the script @@ -34,7 +34,7 @@ class XoopspollUserlogPlugin extends \Userlog_Module_Plugin_Abstract implements * * @return array|bool $item["item_name"] name of the item, $item["item_id"] id of the item */ - public function item($subscribe_from) + public function item(string $subscribe_from) { xoops_load('XoopsRequest'); $poll_id = XoopsRequest::getInt('poll_id', 0); diff --git a/comment_delete.php b/comment_delete.php index 0b90454..ccf5bb2 100644 --- a/comment_delete.php +++ b/comment_delete.php @@ -1,4 +1,4 @@ -path('include/comment_delete.php'); diff --git a/comment_edit.php b/comment_edit.php index 9a3ba55..ce91111 100644 --- a/comment_edit.php +++ b/comment_edit.php @@ -1,4 +1,4 @@ -path('include/comment_edit.php'); diff --git a/comment_new.php b/comment_new.php index dac7295..65b7768 100644 --- a/comment_new.php +++ b/comment_new.php @@ -1,4 +1,4 @@ -path('include/comment_new.php'); diff --git a/comment_post.php b/comment_post.php index bb1651e..e516073 100644 --- a/comment_post.php +++ b/comment_post.php @@ -1,4 +1,4 @@ -path('include/comment_post.php'); diff --git a/comment_reply.php b/comment_reply.php index 0c8bca3..9f5c036 100644 --- a/comment_reply.php +++ b/comment_reply.php @@ -1,4 +1,4 @@ -path('include/comment_reply.php'); diff --git a/config/config.php b/config/config.php index 7819318..d278c0e 100644 --- a/config/config.php +++ b/config/config.php @@ -1,4 +1,4 @@ - $moduleDirNameUpper . ' Module Configurator', @@ -75,30 +75,29 @@ '/tcpdf', ], - 'renameTables' => [// 'XX_archive' => 'ZZZZ_archive', + 'renameTables' => [// 'XX_archive' => 'ZZZZ_archive', + ], + 'renameColumns' => [// 'extcal_event' => ['from' => 'event_etablissement', 'to' => 'event_location'], ], - 'moduleStats' => [ + 'moduleStats' => [ // 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1), // 'totalitems' => $helper->getHandler('Item')->getItemsCount(), // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]), ], - - 'editorConfigs' => [ - // 'editor' => $GLOBALS['xoopsModuleConfig']['useeditor'], - // 'editor' => $xp_config['useeditor'], - 'editor' => $sys_config['general_editor'], - 'rows' => 15, - 'cols' => 60, - 'width' => '100%', - 'height' => '350px', - 'name' => 'description', - // 'value' => $myts->stripSlashesGPC($this->getVar('description')) - 'value' => $myts->htmlSpecialChars($this->getVar('description')), - ], - + /* 'editorConfigs' => [ + // 'editor' => $GLOBALS['xoopsModuleConfig']['useeditor'], + // 'editor' => $xp_config['useeditor'], + 'editor' => $sys_config['general_editor'], + 'rows' => 15, + 'cols' => 60, + 'width' => '100%', + 'height' => '350px', + 'name' => 'description', + // 'value' => ($this->getVar('description')) + 'value' => htmlspecialchars($this->getVar('description'), ENT_QUOTES | ENT_HTML5), + ],*/ 'modCopyright' => " - XOOPS Project", + XOOPS Project", ]; - diff --git a/config/icons.php b/config/icons.php index 58c688b..045b413 100644 --- a/config/icons.php +++ b/config/icons.php @@ -1,19 +1,21 @@ - mb_strtoupper($moduleDirName) . ' IconConfigurator', - 'icons' => [ - 'edit' => " . _EDIT . ", - 'delete' => "" . _DELETE . "", - 'clone' => "" . _CLONE . "", - 'preview' => "" . _PREVIEW . "", - 'print' => "" . _CLONE . "", - 'pdf' => "" . _CLONE . "", - 'add' => "" . _ADD . "", - '0' => "" . 0 . "", - '1' => "" . 1 . "", - ], +$pathIcon16 = Admin::iconUrl('', '16'); +$moduleDirName = \basename(\dirname(__DIR__)); + +return [ + 'name' => \mb_strtoupper($moduleDirName) . ' IconConfigurator', + 'edit' => " . _EDIT . ' title=' . _EDIT . ", + 'delete' => " . _DELETE . ' title=' . _DELETE . ", + 'clone' => " . _CLONE . ' title=' . _CLONE . ", + 'preview' => " . _PREVIEW . ' title=' . _PREVIEW . ", + 'print' => " . _PRINT . ' title=' . _PRINT . ", + 'pdf' => " . _PDF . ' title=' . _PDF . ", + 'add' => " . _ADD . ' title=' . _ADD . ", + '0' => " . 0 . ' title=' . _OFF . ", + '1' => " . 1 . ' title=' . _ON . ", + + 'log' => " . _AM_XOOPSPOLL_VIEWLOG . ' title=' . _AM_XOOPSPOLL_VIEWLOG . ", ]; diff --git a/config/imageconfig.php b/config/imageconfig.php index 26e2408..85852b6 100644 --- a/config/imageconfig.php +++ b/config/imageconfig.php @@ -1,7 +1,7 @@ - 'text', 'default' => 'uploads/' . $modversion['dirname'] . '/images', ]; - diff --git a/config/index.html b/config/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/config/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/config/index.php b/config/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/config/index.php @@ -0,0 +1,3 @@ + mb_strtoupper($moduleDirName) . ' PathConfigurator', - 'paths' => [ - 'dirname' => $moduleDirName, - 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', - 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, - 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, - 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, - ], +return [ + 'name' => \mb_strtoupper($moduleDirName) . ' PathConfigurator', + 'dirname' => $moduleDirName, + 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', + 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, + 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, + 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, + 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, 'uploadFolders' => [ XOOPS_UPLOAD_PATH . '/' . $moduleDirName, XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category', @@ -20,4 +18,3 @@ //XOOPS_UPLOAD_PATH . '/flags' ], ]; - diff --git a/docs/changelog.txt b/docs/changelog.txt index 9815273..f51d961 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,9 +1,16 @@ -
    2.01 Beta 1 [NOT RELEASED]
    Dev: Xoops 2.5.11, PHP 7.4.8 +
    2.1.0 Beta 2 [2023-04-20]
    Dev: XOOPS 2.5.11, PHP 8.2.4 +
    +- small fixes + +
    2.1.0 Beta 1 [2023-04-18]
    Dev: XOOPS 2.5.11, PHP 8.2.4
    - namespaces, autoloading (mamba) - fixed bugs with namespaces in newbb 5.0 (axelf/goffy) - -WORK IN PROGRESS +- cosmetics (mamba) +- PHP8 template defaults (mamba) +- add blocksadmin.php language file (mamba) +- add local deleteBlock() & isDeleteOk() (mamba) +- PHP 8.2 and Smarty 3 updates (mamba)
    1.40 RC3 [2016-09-18]
    diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/docs/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/docs/index.php b/docs/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/docs/index.php @@ -0,0 +1,3 @@ + Preferences -> XOOPS Poll Detailed instructions on installing modules are available in the XOOPS -Operations Manual (http://goo.gl/adT2i) \ No newline at end of file +Operations Manual (https://goo.gl/adT2i) diff --git a/docs/readme.txt b/docs/readme.txt index d96fe75..96644f4 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -17,7 +17,7 @@ Install/uninstall ------------------ No special measures necessary, follow the standard installation process – extract the /xoopspoll folder into the ../modules directory. Install the module through Admin -> System Module -> Modules. -Detailed instructions on installing modules are available in the XOOPS Operations Manual (http://goo.gl/adT2i) +Detailed instructions on installing modules are available in the XOOPS Operations Manual (https://goo.gl/adT2i) Operating instructions ------------------------ @@ -29,7 +29,7 @@ ii) Enter your poll details – including the question and possible answers iii) Check that you have given your user groups the necessary module and block access rights to use this module. Group permissions are set through the Administration Menu -> System -> Groups. -Detailed instructions on configuring the access rights for user groups are available in the XOOPS Operations Manual (http://goo.gl/adT2i) +Detailed instructions on configuring the access rights for user groups are available in the XOOPS Operations Manual (https://goo.gl/adT2i) Tutorial ----------- diff --git a/extras/index.html b/extras/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/extras/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/extras/index.php b/extras/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/marquee/index.php b/extras/marquee/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/marquee/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/marquee/plugins/index.php b/extras/marquee/plugins/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/marquee/plugins/index.php @@ -0,0 +1,3 @@ +path('modules/marquee/include/functions.php'); - $block = []; - $myts = \MyTextSanitizer::getInstance(); + $block = []; + $myts = \MyTextSanitizer::getInstance(); /** @var PollHandler $pollHandler */ $pollHandler = Helper::getInstance()->getHandler('Poll'); $criteria = new \CriteriaCompo(); @@ -55,7 +54,7 @@ function b_marquee_xoopspoll($limit, $dateformat, $itemssize) $pollObjs = $pollHandler->getAll($criteria, $pollFields); foreach ($pollObjs as $pollObj) { $pollValues = $pollObj->getValues(); - $title = $myts->htmlSpecialChars($pollValues['question']); + $title = htmlspecialchars($pollValues['question'], ENT_QUOTES | ENT_HTML5); if ((int)$itemssize > 0) { $title = xoops_substr($title, 0, $itemssize + 3); } diff --git a/extras/newbb_4x/index.html b/extras/newbb_4x/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/extras/newbb_4x/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/extras/newbb_4x/irmtfan/class/index.html b/extras/newbb_4x/irmtfan/class/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/class/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/class/post.php b/extras/newbb_4x/irmtfan/class/post.php deleted file mode 100644 index 86ece7d..0000000 --- a/extras/newbb_4x/irmtfan/class/post.php +++ /dev/null @@ -1,1247 +0,0 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: phppp (D.J., infomax@gmail.com) // -// URL: http://xoopsforge.com, http://xoops.org.cn // -// Project: Article Project // -// ------------------------------------------------------------------------ // - -// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); - -defined('NEWBB_FUNCTIONS_INI') || include XOOPS_ROOT_PATH . '/modules/newbb/include/functions.ini.php'; -newbb_load_object(); - -/** - * Class Post - */ -class Post extends XoopsObject -{ - //class Post extends XoopsObject { - public $attachment_array = array(); - - /** - * Post constructor. - */ - public function __construct() - { - parent::__construct('bb_posts'); - $this->initVar('post_id', XOBJ_DTYPE_INT); - $this->initVar('topic_id', XOBJ_DTYPE_INT, 0, true); - $this->initVar('forum_id', XOBJ_DTYPE_INT, 0, true); - $this->initVar('post_time', XOBJ_DTYPE_INT, 0, true); - $this->initVar('poster_ip', XOBJ_DTYPE_INT, 0); - $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX, ''); - $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true); - $this->initVar('pid', XOBJ_DTYPE_INT, 0); - $this->initVar('dohtml', XOBJ_DTYPE_INT, 0); - $this->initVar('dosmiley', XOBJ_DTYPE_INT, 1); - $this->initVar('doxcode', XOBJ_DTYPE_INT, 1); - $this->initVar('doimage', XOBJ_DTYPE_INT, 1); - $this->initVar('dobr', XOBJ_DTYPE_INT, 1); - $this->initVar('uid', XOBJ_DTYPE_INT, 1); - $this->initVar('icon', XOBJ_DTYPE_TXTBOX, ''); - $this->initVar('attachsig', XOBJ_DTYPE_INT, 0); - $this->initVar('approved', XOBJ_DTYPE_INT, 1); - $this->initVar('post_karma', XOBJ_DTYPE_INT, 0); - $this->initVar('require_reply', XOBJ_DTYPE_INT, 0); - $this->initVar('attachment', XOBJ_DTYPE_TXTAREA, ''); - $this->initVar('post_text', XOBJ_DTYPE_TXTAREA, ''); - $this->initVar('post_edit', XOBJ_DTYPE_TXTAREA, ''); - } - - // //////////////////////////////////////////////////////////////////////////////////// - // attachment functions TODO: there should be a file/attachment management class - /** - * @return array|mixed|null - */ - public function getAttachment() - { - if (count($this->attachment_array)) { - return $this->attachment_array; - } - $attachment = $this->getVar('attachment'); - if (empty($attachment)) { - $this->attachment_array = null; - } else { - $this->attachment_array = @unserialize(base64_decode($attachment)); - } - - return $this->attachment_array; - } - - /** - * @param $attach_key - * @return bool - */ - public function incrementDownload($attach_key) - { - if (!$attach_key) { - return false; - } - $this->attachment_array[(string)$attach_key]['num_download']++; - - return $this->attachment_array[(string)$attach_key]['num_download']; - } - - /** - * @return bool - */ - public function saveAttachment() - { - $attachment_save = ''; - if (is_array($this->attachment_array) && count($this->attachment_array) > 0) { - $attachment_save = base64_encode(serialize($this->attachment_array)); - } - $this->setVar('attachment', $attachment_save); - $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' SET attachment=' . $GLOBALS['xoopsDB']->quoteString($attachment_save) . ' WHERE post_id = ' . $this->getVar('post_id'); - if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) { - //xoops_error($GLOBALS["xoopsDB"]->error()); - return false; - } - - return true; - } - - /** - * @param null $attach_array - * @return bool - */ - public function deleteAttachment($attach_array = null) - { - $attach_old = $this->getAttachment(); - if (!is_array($attach_old) || count($attach_old) < 1) { - return true; - } - $this->attachment_array = array(); - - if ($attach_array === null) { - $attach_array = array_keys($attach_old); - } // to delete all! - if (!is_array($attach_array)) { - $attach_array = array($attach_array); - } - - foreach ($attach_old as $key => $attach) { - if (in_array($key, $attach_array)) { - @unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']); - @unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved']); // delete thumbnails - continue; - } - $this->attachment_array[$key] = $attach; - } - if (is_array($this->attachment_array) && count($this->attachment_array) > 0) { - $attachment_save = base64_encode(serialize($this->attachment_array)); - } else { - $attachment_save = ''; - } - $this->setVar('attachment', $attachment_save); - - return true; - } - - /** - * @param string $name_saved - * @param string $name_display - * @param string $mimetype - * @param int $num_download - * @return bool - */ - public function setAttachment($name_saved = '', $name_display = '', $mimetype = '', $num_download = 0) - { - static $counter = 0; - $this->attachment_array = $this->getAttachment(); - if ($name_saved) { - $key = (string)(time() + $counter++); - $this->attachment_array[$key] = array( - 'name_saved' => $name_saved, - 'name_display' => isset($name_display) ? $name_display : $name_saved, - 'mimetype' => $mimetype, - 'num_download' => isset($num_download) ? (int)$num_download : 0 - ); - } - if (is_array($this->attachment_array)) { - $attachment_save = base64_encode(serialize($this->attachment_array)); - } else { - $attachment_save = null; - } - $this->setVar('attachment', $attachment_save); - - return true; - } - - /** - * TODO: refactor - * @param bool $asSource - * @return string - */ - public function displayAttachment($asSource = false) - { - $post_attachment = ''; - $attachments = $this->getAttachment(); - if (is_array($attachments) && count($attachments) > 0) { - $iconHandler = newbb_getIconHandler(); - $mime_path = $iconHandler->getPath('mime'); - include_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/include/functions.image.php'); - $image_extensions = array('jpg', 'jpeg', 'gif', 'png', 'bmp'); // need improve !!! - $post_attachment .= '
    ' . _MD_ATTACHMENT . ':'; - $post_attachment .= "
    \n"; - // $post_attachment .= '


    '; - foreach ($attachments as $key => $att) { - $file_extension = ltrim(strrchr($att['name_saved'], '.'), '.'); - $filetype = $file_extension; - if (file_exists($GLOBALS['xoops']->path("{$mime_path}/{$filetype}.gif"))) { - $icon_filetype = $GLOBALS['xoops']->url("{$mime_path}/{$filetype}.gif"); - } else { - $icon_filetype = $GLOBALS['xoops']->url("{$mime_path}/unknown.gif"); - } - $file_size = @filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved'])); - $file_size = number_format($file_size / 1024, 2) . ' KB'; - if (in_array(strtolower($file_extension), $image_extensions) - && $GLOBALS['xoopsModuleConfig']['media_allowed'] - ) { - $post_attachment .= '
    ' . $filetype . '  ' . $att['name_display'] . ' (' . $file_size . ')'; - $post_attachment .= '
    ' . newbb_attachmentImage($att['name_saved']); - $isDisplayed = true; - } else { - if (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) { - $post_attachment .= "url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . "/dl_attachment.php?attachid={$key}&post_id=" . $this->getVar('post_id')) - . "'> {$filetype} {$att['name_display']} " . _MD_FILESIZE . ": {$file_size}; " . _MD_HITS . ": {$att['num_download']}"; - } elseif (($GLOBALS['xoopsUser'] instanceof XoopsUser) && $GLOBALS['xoopsUser']->uid() > 0 - && $GLOBALS['xoopsUser']->isActive() - ) { - $post_attachment .= "url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . "/dl_attachment.php?attachid={$key}&post_id=" . $this->getVar('post_id')) . "'> {$filetype} {$att['name_display']} " . _MD_FILESIZE . ": {$file_size}; " . _MD_HITS . ": {$att['num_download']}"; - } else { - $post_attachment .= _MD_NEWBB_SEENOTGUEST; - } - } - $post_attachment .= '
    '; - } - } - - return $post_attachment; - } - // attachment functions - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * @param string $poster_name - * @param string $post_editmsg - * @return bool - */ - public function setPostEdit($poster_name = '', $post_editmsg = '') - { - if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit']) - || (time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60 - || $this->getVar('approved') < 1 - ) { - return true; - } - if (($GLOBALS['xoopsUser'] instanceof XoopsUser) && $GLOBALS['xoopsUser']->isActive()) { - if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $GLOBALS['xoopsUser']->getVar('name')) { - $edit_user = $GLOBALS['xoopsUser']->getVar('name'); - } else { - $edit_user = $GLOBALS['xoopsUser']->getVar('uname'); - } - } - $post_edit = array(); - $post_edit['edit_user'] = $edit_user; // The proper way is to store uid instead of name. However, to save queries when displaying, the current way is ok. - $post_edit['edit_time'] = time(); - $post_edit['edit_msg'] = $post_editmsg; - - $post_edits = $this->getVar('post_edit'); - if (!empty($post_edits)) { - $post_edits = unserialize(base64_decode($post_edits)); - } - if (!is_array($post_edits)) { - $post_edits = array(); - } - $post_edits[] = $post_edit; - $post_edit = base64_encode(serialize($post_edits)); - unset($post_edits); - $this->setVar('post_edit', $post_edit); - - return true; - } - - /** - * @return bool|string - */ - public function displayPostEdit() - { - global $myts; - - if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])) { - return false; - } - - $post_edit = ''; - $post_edits = $this->getVar('post_edit'); - if (!empty($post_edits)) { - $post_edits = unserialize(base64_decode($post_edits)); - } - if (!isset($post_edits) || !is_array($post_edits)) { - $post_edits = array(); - } - if (is_array($post_edits) && count($post_edits) > 0) { - foreach ($post_edits as $postedit) { - $edit_time = (int)$postedit['edit_time']; - $edit_user = $myts->stripSlashesGPC($postedit['edit_user']); - $edit_msg = (!empty($postedit['edit_msg'])) ? $myts->stripSlashesGPC($postedit['edit_msg']) : ''; - // Start irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred) - if (empty($GLOBALS['xoopsModuleConfig']['do_latestedit'])) { - $post_edit = ''; - } - // End irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred) - // START hacked by irmtfan - // display/save all edit records. - $post_edit .= _MD_EDITEDBY . ' ' . $edit_user . ' ' . _MD_ON . ' ' . newbb_formatTimestamp((int)$edit_time) . '
    '; - // if reason is not empty - if ($edit_msg !== '') { - $post_edit .= _MD_EDITEDMSG . ' ' . $edit_msg . '
    '; - } - // START hacked by irmtfan - } - } - - return $post_edit; - } - - /** - * @return array - */ - public function &getPostBody() - { - global $myts; - $GLOBALS['xoopsModuleConfig'] = newbb_load_config(); // irmtfan load all newbb configs - newbb config in blocks activated in some modules like profile - mod_loadFunctions('user', 'newbb'); - mod_loadFunctions('render', 'newbb'); - - $uid = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; - $karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma'); - $user_karma = $karmaHandler->getUserKarma(); - - $post = array(); - $post['attachment'] = false; - $post_text = newbb_displayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr')); - if (newbb_isAdmin($this->getVar('forum_id')) or $this->checkIdentity()) { - $post['text'] = $post_text . '
    ' . $this->displayAttachment(); - } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) { - $post['text'] = sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')); - } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply') - && (!$uid - || !isset($viewtopic_users[$uid])) - ) { - $post['text'] = _MD_REPLY_REQUIREMENT; - } else { - $post['text'] = $post_text . '
    ' . $this->displayAttachment(); - } - $memberHandler = xoops_getHandler('member'); - $eachposter = $memberHandler->getUser($this->getVar('uid')); - if (is_object($eachposter) && $eachposter->isActive()) { - if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $eachposter->getVar('name')) { - $post['author'] = $eachposter->getVar('name'); - } else { - $post['author'] = $eachposter->getVar('uname'); - } - unset($eachposter); - } else { - $post['author'] = $this->getVar('poster_name') ?: $GLOBALS['xoopsConfig']['anonymous']; - } - - $post['subject'] = newbb_htmlspecialchars($this->vars['subject']['value']); - $post['date'] = $this->getVar('post_time'); - - return $post; - } - - /** - * @return bool - */ - public function isTopic() - { - return !$this->getVar('pid'); - } - - /** - * @param string $action_tag - * @return bool - */ - public function checkTimelimit($action_tag = 'edit_timelimit') - { - $newbb_config = newbb_load_config(); - if (empty($newbb_config['edit_timelimit'])) { - return true; - } - - return ($this->getVar('post_time') > time() - $newbb_config[$action_tag] * 60); - } - - /** - * @param int $uid - * @return bool - */ - public function checkIdentity($uid = -1) - { - $uid = ($uid > -1) ? $uid : (($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0); - if ($this->getVar('uid') > 0) { - $user_ok = ($uid === $this->getVar('uid')) ? true : false; - } else { - static $user_ip; - if (!isset($user_ip)) { - $user_ip = XoopsUserUtility::getIP(); - } - $user_ok = ($user_ip === $this->getVar('poster_ip')) ? true : false; - } - - return $user_ok; - } - - // TODO: cleaning up and merge with post hanldings in viewpost.php - /** - * @param $isadmin - * @return array - */ - public function showPost($isadmin) - { - global $myts; - global $forumUrl, $forumImage; - global $viewtopic_users, $viewtopic_posters, $forum_obj, $topic_obj, $online, $user_karma, $viewmode, $order, $start, $total_posts, $topic_status; - static $post_NO = 0; - static $name_anonymous; - - if (!isset($name_anonymous)) { - $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); - } - - mod_loadFunctions('time', 'newbb'); - mod_loadFunctions('render', 'newbb'); - mod_loadFunctions('text', 'newbb'); // irmtfan add text functions - - $post_id = $this->getVar('post_id'); - $topic_id = $this->getVar('topic_id'); - $forum_id = $this->getVar('forum_id'); - - $query_vars = array('status', 'order', 'start', 'mode', 'viewmode'); - $query_array = array(); - $query_array['topic_id'] = "topic_id={$topic_id}"; - foreach ($query_vars as $var) { - if (!empty($_GET[$var])) { - $query_array[$var] = "{$var}={$_GET[$var]}"; - } - } - $page_query = htmlspecialchars(implode('&', array_values($query_array))); - - $uid = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; - - ++$post_NO; - if (strtolower($order) === 'desc') { - $post_no = $total_posts - ($start + $post_NO) + 1; - } else { - $post_no = $start + $post_NO; - } - - if ($isadmin || $this->checkIdentity()) { - $post_text = $this->getVar('post_text'); - $post_attachment = $this->displayAttachment(); - } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) { - $post_text = "
    " . sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '
    '; - $post_attachment = ''; - } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply') - && (!$uid - || !in_array($uid, $viewtopic_posters)) - ) { - $post_text = "
    " . _MD_REPLY_REQUIREMENT . "
    \n"; - $post_attachment = ''; - } else { - $post_text = $this->getVar('post_text'); - $post_attachment = $this->displayAttachment(); - } - // START irmtfan add highlight feature - // Hightlighting searched words - $post_title = $this->getVar('subject'); - if (isset($_GET['keywords']) && !empty($_GET['keywords'])) { - $keywords = $myts->htmlSpecialChars(trim(urldecode($_GET['keywords']))); - $post_text = newbb_highlightText($post_text, $keywords); - $post_title = newbb_highlightText($post_title, $keywords); - } - // END irmtfan add highlight feature - if (isset($viewtopic_users[$this->getVar('uid')])) { - $poster = $viewtopic_users[$this->getVar('uid')]; - } else { - $name = ($post_name = $this->getVar('poster_name')) ? $post_name : $name_anonymous; - $poster = array( - 'poster_uid' => 0, - 'name' => $name, - 'link' => $name - ); - } - - if ($posticon = $this->getVar('icon')) { - $post_image = "url("images/subject/{$posticon}") . "' alt='' />"; - } else { - $post_image = "url('images/icons/posticon.gif') . "' alt='' />"; - } - - $thread_buttons = array(); - $mod_buttons = array(); - - if ($isadmin - && (($GLOBALS['xoopsUser'] instanceof XoopsUser) - && $GLOBALS['xoopsUser']->getVar('uid') !== $this->getVar('uid')) - && ($this->getVar('uid') > 0) - ) { - $mod_buttons['bann']['image'] = newbb_displayImage('p_bann', _MD_SUSPEND_MANAGEMENT); - $mod_buttons['bann']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/moderate.php?forum={$forum_id}&fuid=" . $this->getVar('uid')); - $mod_buttons['bann']['name'] = _MD_SUSPEND_MANAGEMENT; - $thread_buttons['bann']['image'] = newbb_displayImage('p_bann', _MD_SUSPEND_MANAGEMENT); - $thread_buttons['bann']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/moderate.php?forum={$forum_id}&fuid=" . $this->getVar('uid')); - $thread_buttons['bann']['name'] = _MD_SUSPEND_MANAGEMENT; - } - - if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) { - /** @var NewbbTopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - $topic_status = $topic_obj->getVar('topic_status'); - if ($topicHandler->getPermission($forum_id, $topic_status, 'edit')) { - $edit_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit'))); - if ($edit_ok) { - $thread_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT); - $thread_buttons['edit']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}"); - $thread_buttons['edit']['name'] = _EDIT; - $mod_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT); - $mod_buttons['edit']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}"); - $mod_buttons['edit']['name'] = _EDIT; - } - } - - if ($topicHandler->getPermission($forum_id, $topic_status, 'delete')) { - $delete_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit'))); - - if ($delete_ok) { - $thread_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE); - $thread_buttons['delete']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}"); - $thread_buttons['delete']['name'] = _DELETE; - $mod_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE); - $mod_buttons['delete']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}"); - $mod_buttons['delete']['name'] = _DELETE; - } - } - if ($topicHandler->getPermission($forum_id, $topic_status, 'reply')) { - $thread_buttons['reply']['image'] = newbb_displayImage('p_reply', _MD_REPLY); - $thread_buttons['reply']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}"); - $thread_buttons['reply']['name'] = _MD_REPLY; - - $thread_buttons['quote']['image'] = newbb_displayImage('p_quote', _MD_QUOTE); - $thread_buttons['quote']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}&quotedac=1"); - $thread_buttons['quote']['name'] = _MD_QUOTE; - } - } else { - $mod_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT); - $mod_buttons['edit']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}"); - $mod_buttons['edit']['name'] = _EDIT; - - $mod_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE); - $mod_buttons['delete']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}"); - $mod_buttons['delete']['name'] = _DELETE; - - $thread_buttons['reply']['image'] = newbb_displayImage('p_reply', _MD_REPLY); - $thread_buttons['reply']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}"); - $thread_buttons['reply']['name'] = _MD_REPLY; - } - - if (!$isadmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) { - $thread_buttons['report']['image'] = newbb_displayImage('p_report', _MD_REPORT); - $thread_buttons['report']['link'] = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/report.php?{$page_query}"); - $thread_buttons['report']['name'] = _MD_REPORT; - } - - $thread_action = array(); - // irmtfan add pdf permission - if (file_exists($GLOBALS['xoops']->path('Frameworks/tcpdf/tcpdf.php')) - && $topicHandler->getPermission($forum_id, $topic_status, 'pdf') - ) { - $thread_action['pdf']['image'] = newbb_displayImage('pdf', _MD_PDF); - $thread_action['pdf']['link'] = $GLOBALS['xoops']->url('modules/newbb/makepdf.php?type=post&pageid=0'); - $thread_action['pdf']['name'] = _MD_PDF; - $thread_action['pdf']['target'] = '_blank'; - } - // irmtfan add print permission - if ($topicHandler->getPermission($forum_id, $topic_status, 'print')) { - $thread_action['print']['image'] = newbb_displayImage('printer', _MD_PRINT); - $thread_action['print']['link'] = $GLOBALS['xoops']->url("modules/newbb/print.php?form=2&forum={$forum_id}&topic_id={$topic_id}"); - $thread_action['print']['name'] = _MD_PRINT; - $thread_action['print']['target'] = '_blank'; - } - - if ($GLOBALS['xoopsModuleConfig']['show_sociallinks']) { - $full_title = $this->getVar('subject'); - $clean_title = preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject')); - $full_link = $GLOBALS['xoops']->url("modules/newbb/viewtopic.php?post_id={$post_id}"); - - $thread_action['social_twitter']['image'] = newbb_displayImage('twitter', _MD_SHARE_TWITTER); - $thread_action['social_twitter']['link'] = "http://twitter.com/share?text={$clean_title}&url={$full_link}"; - $thread_action['social_twitter']['name'] = _MD_SHARE_TWITTER; - $thread_action['social_twitter']['target'] = '_blank'; - - $thread_action['social_facebook']['image'] = newbb_displayImage('facebook', _MD_SHARE_FACEBOOK); - $thread_action['social_facebook']['link'] = "http://www.facebook.com/sharer.php?u={$full_link}"; - $thread_action['social_facebook']['name'] = _MD_SHARE_FACEBOOK; - $thread_action['social_facebook']['target'] = '_blank'; - - $thread_action['social_gplus']['image'] = newbb_displayImage('googleplus', _MD_SHARE_GOOGLEPLUS); - $thread_action['social_gplus']['link'] = "https://plusone.google.com/_/+1/confirm?hl=en&url={$full_link}"; - $thread_action['social_gplus']['name'] = _MD_SHARE_GOOGLEPLUS; - $thread_action['social_gplus']['target'] = '_blank'; - - $thread_action['social_linkedin']['image'] = newbb_displayImage('linkedin', _MD_SHARE_LINKEDIN); - $thread_action['social_linkedin']['link'] = "http://www.linkedin.com/shareArticle?mini=true&title={$full_title}&url={$full_link}"; - $thread_action['social_linkedin']['name'] = _MD_SHARE_LINKEDIN; - $thread_action['social_linkedin']['target'] = '_blank'; - - $thread_action['social_delicious']['image'] = newbb_displayImage('delicious', _MD_SHARE_DELICIOUS); - $thread_action['social_delicious']['link'] = "http://del.icio.us/post?title={$full_title}&url={$full_link}"; - $thread_action['social_delicious']['name'] = _MD_SHARE_DELICIOUS; - $thread_action['social_delicious']['target'] = '_blank'; - - $thread_action['social_digg']['image'] = newbb_displayImage('digg', _MD_SHARE_DIGG); - $thread_action['social_digg']['link'] = "http://digg.com/submit?phase=2&title={$full_title}&url={$full_link}"; - $thread_action['social_digg']['name'] = _MD_SHARE_DIGG; - $thread_action['social_digg']['target'] = '_blank'; - - $thread_action['social_reddit']['image'] = newbb_displayImage('reddit', _MD_SHARE_REDDIT); - $thread_action['social_reddit']['link'] = "http://reddit.com/submit?title={$full_title}&url={$full_link}"; - $thread_action['social_reddit']['name'] = _MD_SHARE_REDDIT; - $thread_action['social_reddit']['target'] = '_blank'; - - $thread_action['social_wong']['image'] = newbb_displayImage('wong', _MD_SHARE_MRWONG); - $thread_action['social_wong']['link'] = "http://www.mister-wong.de/index.php?action=addurl&bm_url=$full_link}"; - $thread_action['social_wong']['name'] = _MD_SHARE_MRWONG; - $thread_action['social_wong']['target'] = '_blank'; - } - - $post = array( - 'post_id' => $post_id, - 'post_parent_id' => $this->getVar('pid'), - 'post_date' => newbb_formatTimestamp($this->getVar('post_time')), - 'post_image' => $post_image, - 'post_title' => $post_title, // irmtfan $post_title to add highlight keywords - 'post_text' => $post_text, - 'post_attachment' => $post_attachment, - 'post_edit' => $this->displayPostEdit(), - 'post_no' => $post_no, - 'post_signature' => $this->getVar('attachsig') ? @$poster['signature'] : '', - 'poster_ip' => ($isadmin - && $GLOBALS['xoopsModuleConfig']['show_ip']) ? long2ip($this->getVar('poster_ip')) : '', - 'thread_action' => $thread_action, - 'thread_buttons' => $thread_buttons, - 'mod_buttons' => $mod_buttons, - 'poster' => $poster, - 'post_permalink' => "url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/viewtopic.php?post_id={$post_id}") . "'>" - ); - - unset($thread_buttons, $mod_buttons, $eachposter); - - return $post; - } -} - -/** - * Class NewbbPostHandler - */ -//class NewbbPostHandler extends ArtObjectHandler -class NewbbPostHandler extends XoopsPersistableObjectHandler -{ - /** - * @param null|XoopsDatabase $db - */ - public function __construct(XoopsDatabase $db) - { - parent::__construct($db, 'bb_posts', 'Post', 'post_id', 'subject'); - } - - /** - * @param mixed|null $id - * @return null|XoopsObject - */ - public function get($id) - { - $id = (int)$id; - $post = null; - $sql = 'SELECT p.*, t.* FROM ' . $this->db->prefix('bb_posts') . ' p LEFT JOIN ' . $this->db->prefix('bb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id; - if ($array = $this->db->fetchArray($this->db->query($sql))) { - $post = $this->create(false); - $post->assignVars($array); - } - - return $post; - } - - /** - * @param int $topic_id - * @param int $limit - * @param int $approved - * @return array - */ - public function &getByLimit($topic_id, $limit, $approved = 1) - { - $sql = 'SELECT p.*, t.*, tp.topic_status FROM ' . $this->db->prefix('bb_posts') . ' p LEFT JOIN ' . $this->db->prefix('bb_posts_text') . ' t ON p.post_id=t.post_id LEFT JOIN ' . $this->db->prefix('bb_topics') - . ' tp ON tp.topic_id=p.topic_id WHERE p.topic_id=' . $topic_id . ' AND p.approved =' . $approved . ' ORDER BY p.post_time DESC'; - $result = $this->db->query($sql, $limit, 0); - $ret = array(); - while ($myrow = $this->db->fetchArray($result)) { - $post = $this->create(false); - $post->assignVars($myrow); - - $ret[$myrow['post_id']] = $post; - unset($post); - } - - return $ret; - } - - /** - * @param $post - * @return mixed - */ - public function getPostForPDF(&$post) - { - return $post->getPostBody(true); - } - - /** - * @param $post - * @return mixed - */ - public function getPostForPrint(&$post) - { - return $post->getPostBody(); - } - - /** - * @param $post - * @param bool $force - * @return bool - */ - public function approve(&$post, $force = false) - { - if (empty($post)) { - return false; - } - if (is_numeric($post)) { - $post = $this->get($post); - } - $post_id = $post->getVar('post_id'); - - $wasApproved = $post->getVar('approved'); - // irmtfan approve post if the approved = 0 (pending) or -1 (deleted) - if (empty($force) && $wasApproved > 0) { - return true; - } - $post->setVar('approved', 1); - $this->insert($post, true); - - /** @var NewbbTopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - $topic_obj = $topicHandler->get($post->getVar('topic_id')); - if ($topic_obj->getVar('topic_last_post_id') < $post->getVar('post_id')) { - $topic_obj->setVar('topic_last_post_id', $post->getVar('post_id')); - } - if ($post->isTopic()) { - $topic_obj->setVar('approved', 1); - } else { - $topic_obj->setVar('topic_replies', $topic_obj->getVar('topic_replies') + 1); - } - $topicHandler->insert($topic_obj, true); - - /** @var NewbbForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); - $forum_obj = $forumHandler->get($post->getVar('forum_id')); - if ($forum_obj->getVar('forum_last_post_id') < $post->getVar('post_id')) { - $forum_obj->setVar('forum_last_post_id', $post->getVar('post_id')); - } - $forum_obj->setVar('forum_posts', $forum_obj->getVar('forum_posts') + 1); - if ($post->isTopic()) { - $forum_obj->setVar('forum_topics', $forum_obj->getVar('forum_topics') + 1); - } - $forumHandler->insert($forum_obj, true); - - // Update user stats - if ($post->getVar('uid') > 0) { - $memberHandler = xoops_getHandler('member'); - $poster = $memberHandler->getUser($post->getVar('uid')); - if (is_object($poster) && $post->getVar('uid') === $poster->getVar('uid')) { - $poster->setVar('posts', $poster->getVar('posts') + 1); - $res = $memberHandler->insertUser($poster, true); - unset($poster); - } - } - - // Update forum stats - $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); - $statsHandler->update($post->getVar('forum_id'), 'post'); - if ($post->isTopic()) { - $statsHandler->update($post->getVar('forum_id'), 'topic'); - } - - return true; - } - - /** - * @param XoopsObject $post - * @param bool $force - * @return bool - */ - public function insert(XoopsObject $post, $force = true) - { - // Set the post time - // The time should be 'publish' time. To be adjusted later - if (!$post->getVar('post_time')) { - $post->setVar('post_time', time()); - } - - /** @var NewbbTopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - // Verify the topic ID - if ($topic_id = $post->getVar('topic_id')) { - $topic_obj = $topicHandler->get($topic_id); - // Invalid topic OR the topic is no approved and the post is not top post - if (!$topic_obj - // || (!$post->isTopic() && $topic_obj->getVar("approved") < 1) - ) { - return false; - } - } - if (empty($topic_id)) { - $post->setVar('topic_id', 0); - $post->setVar('pid', 0); - $post->setNew(); - $topic_obj = $topicHandler->create(); - } - $textHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Text'); - $post_text_vars = array('post_text', 'post_edit', 'dohtml', 'doxcode', 'dosmiley', 'doimage', 'dobr'); - if ($post->isNew()) { - if (!$topic_id = $post->getVar('topic_id')) { - $topic_obj->setVar('topic_title', $post->getVar('subject', 'n')); - $topic_obj->setVar('topic_poster', $post->getVar('uid')); - $topic_obj->setVar('forum_id', $post->getVar('forum_id')); - $topic_obj->setVar('topic_time', $post->getVar('post_time')); - $topic_obj->setVar('poster_name', $post->getVar('poster_name'), true); - $topic_obj->setVar('approved', $post->getVar('approved'), true); - - if (!$topic_id = $topicHandler->insert($topic_obj, $force)) { - $post->deleteAttachment(); - $post->setErrors('insert topic error'); - - //xoops_error($topic_obj->getErrors()); - return false; - } - $post->setVar('topic_id', $topic_id); - - $pid = 0; - $post->setVar('pid', 0); - } elseif (!$post->getVar('pid')) { - $pid = $topicHandler->getTopPostId($topic_id); - $post->setVar('pid', $pid); - } - - $text_obj = $textHandler->create(); - foreach ($post_text_vars as $key) { - $text_obj->vars[$key] = $post->vars[$key]; - } - $post->destroyVars($post_text_vars); - if (!$post_id = parent::insert($post, $force)) { - return false; - } else { - $post->unsetNew(); - } - $text_obj->setVar('post_id', $post_id); - if (!$textHandler->insert($text_obj, $force)) { - $this->delete($post); - $post->setErrors('post text insert error'); - - //xoops_error($text_obj->getErrors()); - return false; - } - if ($post->getVar('approved') > 0) { - $this->approve($post, true); - } - $post->setVar('post_id', $post_id); - } else { - if ($post->isTopic()) { - if ($post->getVar('subject') !== $topic_obj->getVar('topic_title')) { - $topic_obj->setVar('topic_title', $post->getVar('subject', 'n')); - } - if ($post->getVar('approved') !== $topic_obj->getVar('approved')) { - $topic_obj->setVar('approved', $post->getVar('approved')); - } - $topic_obj->setDirty(); - if (!$result = $topicHandler->insert($topic_obj, $force)) { - $post->setErrors('update topic error'); - - // xoops_error($topic_obj->getErrors()); - return false; - } - } - $text_obj =& $textHandler->get($post->getVar('post_id')); - $text_obj->setDirty(); - foreach ($post_text_vars as $key) { - $text_obj->vars[$key] = $post->vars[$key]; - } - $post->destroyVars($post_text_vars); - if (!$post_id = parent::insert($post, $force)) { - // xoops_error($post->getErrors()); - return false; - } else { - $post->unsetNew(); - } - if (!$textHandler->insert($text_obj, $force)) { - $post->setErrors('update post text error'); - - // xoops_error($text_obj->getErrors()); - return false; - } - } - - return $post->getVar('post_id'); - } - - /** - * @param XoopsObject $post - * @param bool $isDeleteOne - * @param bool $force - * @return bool - */ - public function delete($post, $isDeleteOne = true, $force = false) - { - $retVal = false; - if (($post instanceof Post) && ($post->getVar('post_id') > 0)) { - if ($isDeleteOne) { - if ($post->isTopic()) { - $criteria = new CriteriaCompo(new Criteria('topic_id', $post->getVar('topic_id'))); - $criteria->add(new Criteria('approved', 1)); - $criteria->add(new Criteria('pid', 0, '>')); - if (!$this->getPostCount($criteria) > 0) { - $retVal = $this->_delete($post, $force); - } - } else { - $retVal = $this->_delete($post, $force); - } - } else { // want to delete multiple posts - //@TODO: test replacement of XoopsTree with XoopsObjectTree - require_once $GLOBALS['xoops']->path('class/tree.php'); - // get tree with this object as the root - $myObjTree = new XoopsObjectTree($this->getAll(), 'post_id', 'pid', $post->getVar('post_id')); - $arr = $myObjtree->getAllChild(); // get all children of this object - /* - require_once $GLOBALS['xoops']->path("class/xoopstree.php"); - $mytree = new XoopsTree($this->db->prefix("bb_posts"), "post_id", "pid"); - $arr = $mytree->getAllChild($post->getVar('post_id')); - */ - // irmtfan - delete children in a reverse order - $success = true; - for ($i = count($arr) - 1; $i >= 0; $i--) { - $childpost = $this->create(false); - $childpost->assignVars($arr[$i]); - $thisSuccess = $this->_delete($childpost, $force); - $success = $success && $thisSuccess; - unset($childpost); - } - if ($success) { - // if we successfully deleted all children then try and delete this post - $retVal = $this->_delete($post, $force); - } else { - // did not successfully delte all children so don't delete this post - $retVal = false; - } - } - } - - return $retVal; - } - - /** - * @param $post - * @param bool $force - * @return bool - */ - private function _delete(&$post, $force = false) - { - if ((!$post instanceof Post) || (0 === $post->getVar('post_id'))) { - return false; - } - - /* Set active post as deleted */ - if (($post->getVar('approved') > 0) && empty($force)) { - $sql = 'UPDATE ' . $this->db->prefix('bb_posts') . ' SET approved = -1 WHERE post_id = ' . $post->getVar('post_id'); - if (!$result = $this->db->queryF($sql)) { - //@TODO: add error check here - } - } else { /* delete pending post directly */ - $sql = sprintf('DELETE FROM %s WHERE post_id = %u', $this->db->prefix('bb_posts'), $post->getVar('post_id')); - if (!$result = $this->db->queryF($sql)) { - $post->setErrors('delte post error: ' . $sql); - - return false; - } - $post->deleteAttachment(); - - $sql = sprintf('DELETE FROM %s WHERE post_id = %u', $this->db->prefix('bb_posts_text'), $post->getVar('post_id')); - if (!$result = $this->db->queryF($sql)) { - $post->setErrors('Could not remove post text: ' . $sql); - - return false; - } - } - - if ($post->isTopic()) { - /** @var NewbbTopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - $topic_obj = $topicHandler->get($post->getVar('topic_id')); - if (is_object($topic_obj) && $topic_obj->getVar('approved') > 0 && empty($force)) { - $topiccount_toupdate = 1; - $topic_obj->setVar('approved', -1); - $topicHandler->insert($topic_obj); - xoops_notification_deletebyitem($GLOBALS['xoopsModule']->getVar('mid'), 'thread', $post->getVar('topic_id')); - } else { - if (is_object($topic_obj)) { - if ($topic_obj->getVar('approved') > 0) { - xoops_notification_deletebyitem($GLOBALS['xoopsModule']->getVar('mid'), 'thread', $post->getVar('topic_id')); - } - - $poll_id = $topic_obj->getVar('poll_id'); - /** @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - if ($poll_id > 0) { - $poll_moduleHandler = $moduleHandler->getByDirname('xoopspoll'); - if (($poll_moduleHandler instanceof XoopsModuleHandler) && $poll_moduleHandler->isactive()) { - $pollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); - if (false !== $pollHandler->deleteAll(new Criteria('poll_id', $poll_id, '='))) { - $optionHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $optionHandler->deleteAll(new Criteria('poll_id', $poll_id, '=')); - $logHandler = xoops_getModuleHandler('log', 'xoopspoll'); - $logHandler->deleteAll(new Criteria('poll_id', $poll_id, '=')); - xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); - } - } else { - $poll_moduleHandler = $moduleHandler->getByDirname('umfrage'); - if (($poll_moduleHandler instanceof XoopsModuleHandler) - && $poll_moduleHandler->isactive() - ) { - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrage.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrageoption.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragelog.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragerenderer.php'); - - $poll = new Umfrage($poll_id); - if (false !== $poll->delete()) { - UmfrageOption::deleteByPollId($poll_id); - UmfrageLog::deleteByPollId($poll_id); - xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); - } - } - } - } - } - - $sql = sprintf('DELETE FROM %s WHERE topic_id = %u', $this->db->prefix('bb_topics'), $post->getVar('topic_id')); - if (!$result = $this->db->queryF($sql)) { - // xoops_error($this->db->error()); - } - $sql = sprintf('DELETE FROM %s WHERE topic_id = %u', $this->db->prefix('bb_votedata'), $post->getVar('topic_id')); - if (!$result = $this->db->queryF($sql)) { - // xoops_error($this->db->error()); - } - } - } else { - $sql = 'UPDATE ' . $this->db->prefix('bb_topics') . ' t ' . 'LEFT JOIN ' . $this->db->prefix('bb_posts') . ' p ON p.topic_id = t.topic_id ' . 'SET t.topic_last_post_id = p.post_id ' . 'WHERE t.topic_last_post_id = ' - . $post->getVar('post_id') . ' ' . 'AND p.post_id = (SELECT MAX(post_id) FROM ' . $this->db->prefix('bb_posts') . ' ' . 'WHERE topic_id=t.topic_id)'; - if (!$result = $this->db->queryF($sql)) { - //@TODO: add error checking here - } - } - - $postcount_toupdate = $post->getVar('approved'); - - if ($postcount_toupdate > 0) { - // Update user stats - if ($post->getVar('uid') > 0) { - $memberHandler = xoops_getHandler('member'); - $poster = $memberHandler->getUser($post->getVar('uid')); - if (is_object($poster) && $post->getVar('uid') === $poster->getVar('uid')) { - $poster->setVar('posts', $poster->getVar('posts') - 1); - $res = $memberHandler->insertUser($poster, true); - unset($poster); - } - } - // irmtfan - just update the pid for approved posts when the post is not topic (pid=0) - if (!$post->isTopic()) { - $sql = 'UPDATE ' . $this->db->prefix('bb_posts') . ' SET pid = ' . $post->getVar('pid') . ' WHERE approved=1 AND pid=' . $post->getVar('post_id'); - if (!$result = $this->db->queryF($sql)) { - // xoops_error($this->db->error()); - } - } - } - - return true; - } - - // START irmtfan enhance getPostCount when there is join (read_mode = 2) - /** - * @param null $criteria - * @param null $join - * @return int|null - */ - public function getPostCount($criteria = null, $join = null) - { - // If not join get the count from XOOPS/class/model/stats as before - if (empty($join)) { - return parent::getCount($criteria); - } - - $sql = 'SELECT COUNT(*) AS count' . ' ' . 'FROM ' . $this->db->prefix('bb_posts') . ' AS p' . ' ' . 'LEFT JOIN ' . $this->db->prefix('bb_posts_text') . ' ' . 'AS t ON t.post_id = p.post_id'; - // LEFT JOIN - $sql .= $join; - // WHERE - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { - $sql .= ' ' . $criteria->renderWhere(); - } - if (!$result = $this->db->query($sql)) { - // xoops_error($this->db->error().'
    '.$sql); - return null; - } - $myrow = $this->db->fetchArray($result); - $count = $myrow['count']; - - return $count; - } - // END irmtfan enhance getPostCount when there is join (read_mode = 2) - - /* - *@TODO: combining viewtopic.php - */ - /** - * @param null $criteria - * @param int $limit - * @param int $start - * @param null $join - * @return array - */ - public function &getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join = null) - { - $ret = array(); - $sql = 'SELECT p.*, t.* ' . 'FROM ' . $this->db->prefix('bb_posts') . ' AS p ' . 'LEFT JOIN ' . $this->db->prefix('bb_posts_text') . ' AS t ON t.post_id = p.post_id'; - if (!empty($join)) { - $sql .= (substr($join, 0, 1) === ' ') ? $join : ' ' . $join; - } - if (isset($criteria) && is_subclass_of($criteria, 'CriteriaElement')) { - $sql .= ' ' . $criteria->renderWhere(); - if ($criteria->getSort() !== '') { - $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); - } - } - $result = $this->db->query($sql, (int)$limit, (int)$start); - if (!$result) { - // xoops_error($this->db->error()); - return $ret; - } - while ($myrow = $this->db->fetchArray($result)) { - $post = $this->create(false); - $post->assignVars($myrow); - $ret[$myrow['post_id']] = $post; - unset($post); - } - - return $ret; - } - - /** - * @return bool - */ - public function synchronization() - { - // $this->cleanOrphan(); - return true; - } - - /** - * clean orphan items from database - * - * @return bool true on success - */ - public function cleanOrphan() - { - $this->deleteAll(new Criteria('post_time', 0), true, true); - parent::cleanOrphan($this->db->prefix('bb_topics'), 'topic_id'); - parent::cleanOrphan($this->db->prefix('bb_posts_text'), 'post_id'); - - if ($this->mysql_major_version() >= 4) { /* for MySQL 4.1+ */ - $sql = 'DELETE FROM ' . $this->db->prefix('bb_posts_text') . ' ' . 'WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM ' . $this->table . ') )'; - } else { /* for 4.0+ */ - /* */ - $sql = 'DELETE ' . $this->db->prefix('bb_posts_text') . ' FROM ' . $this->db->prefix('bb_posts_text') . ' ' . 'LEFT JOIN ' . $this->table . ' AS aa ON ' . $this->db->prefix('bb_posts_text') . '.post_id = aa.post_id ' . ' ' - . 'WHERE (aa.post_id IS NULL)'; - /* */ - // Alternative for 4.1+ - /* - $sql = "DELETE bb FROM ".$this->db->prefix("bb_posts_text")." AS bb" . " " - . "LEFT JOIN ".$this->table." AS aa ON bb.post_id = aa.post_id " . " " - . "WHERE (aa.post_id IS NULL)"; - */ - } - if (!$result = $this->db->queryF($sql)) { - // xoops_error($this->db->error()); - return false; - } - - return true; - } - - /** - * clean expired objects from database - * - * @param int $expire time limit for expiration - * @return bool true on success - */ - public function cleanExpires($expire = 0) - { - // irmtfan if 0 no cleanup look include/plugin.php - if (!func_num_args()) { - $newbbConfig = newbb_load_config(); - $expire = isset($newbbConfig['pending_expire']) ? (int)$newbbConfig['pending_expire'] : 7; - $expire = $expire * 24 * 3600; // days to seconds - } - if (empty($expire)) { - return false; - } - $crit_expire = new CriteriaCompo(new Criteria('approved', 0, '<=')); - // if (!empty($expire)) { - $crit_expire->add(new Criteria('post_time', time() - (int)$expire, '<')); - - // } - return $this->deleteAll($crit_expire, true/*, true*/); - } -} diff --git a/extras/newbb_4x/irmtfan/class/userlanguage.php b/extras/newbb_4x/irmtfan/class/userlanguage.php deleted file mode 100644 index 73b3510..0000000 --- a/extras/newbb_4x/irmtfan/class/userlanguage.php +++ /dev/null @@ -1,88 +0,0 @@ -path('modules/newbb/class/user.php'); - -/** - * - * Allows setting for user information - * If you have a customized userbar, define it here. - * - */ -class User_language extends User -{ - - /** - * User_language constructor. - * @param $user - */ - public function __construct($user) - { - parent::__construct($user); - } - - /** - * @return array|null - */ - public function getUserbar() - { - global $xoopsModuleConfig, $xoopsUser, $isadmin; - if (empty($GLOBALS['xoopsModuleConfig']['userbar_enabled'])) { - return null; - } - $user = $this->user; - $userbar = []; - $userbar[] = [ - 'link' => $GLOBALS['xoops']->url('userinfo.php?uid=' . $user->getVar('uid')), - 'name' => PROFILE - ]; - if (is_object($xoopsUser)) { - $userbar[] = [ - 'link' => "javascript:void openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $user->getVar('uid') . "','pmlite', 450, 380);", - 'name' => _MD_PM - ]; - } - if ($user->getVar('user_viewemail') || $isadmin) { - $userbar[] = [ - 'link' => "javascript:void window.open('mailto:" . $user->getVar('email') . "','new');", - 'name' => _MD_EMAIL - ]; - } - if ($user->getVar('url')) { - $userbar[] = [ - 'link' => "javascript:void window.open('" . $user->getVar('url') . "','new');", - 'name' => _MD_WWW - ]; - } - if ($user->getVar('user_icq')) { - $userbar[] = [ - 'link' => "javascript:void window.open('http://wwp.icq.com/scripts/search.dll?to=" . $user->getVar('user_icq') . "','new');", - 'name' => _MD_ICQ - ]; - } - if ($user->getVar('user_aim')) { - $userbar[] = [ - 'link' => "javascript:void window.open('aim:goim?screenname=" . $user->getVar('user_aim') . '&message=Hi+' . $user->getVar('user_aim') . '+Are+you+there?' . "','new');", - 'name' => _MD_AIM - ]; - } - if ($user->getVar('user_yim')) { - $userbar[] = [ - 'link' => "javascript:void window.open('http://edit.yahoo.com/config/send_webmesg?.target=" . $user->getVar('user_yim') . '&.src=pg' . "','new');", - 'name' => _MD_YIM - ]; - } - if ($user->getVar('user_msnm')) { - $userbar[] = [ - 'link' => "javascript:void window.open('http://members.msn.com?mem=" . $user->getVar('user_msnm') . "','new');", - 'name' => _MD_MSNM - ]; - } - - return $userbar; - } -} diff --git a/extras/newbb_4x/irmtfan/index.html b/extras/newbb_4x/irmtfan/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/language/english/index.html b/extras/newbb_4x/irmtfan/language/english/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/language/english/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/language/english/main.php b/extras/newbb_4x/irmtfan/language/english/main.php deleted file mode 100644 index 24af0d6..0000000 --- a/extras/newbb_4x/irmtfan/language/english/main.php +++ /dev/null @@ -1,539 +0,0 @@ -can access the forum.
    '); -define('_MD_CANNOT_ACCESS', 'You cannot access the forum.
    '); -define('_MD_CAN_POST', 'You can start a new topic.
    '); -define('_MD_CANNOT_POST', 'You cannot start a new topic.
    '); -define('_MD_CAN_VIEW', 'You can view topic.
    '); -define('_MD_CANNOT_VIEW', 'You cannot view topic.
    '); -define('_MD_CAN_REPLY', 'You can reply to posts.
    '); -define('_MD_CANNOT_REPLY', 'You cannot reply to posts.
    '); -define('_MD_CAN_EDIT', 'You can edit your posts.
    '); -define('_MD_CANNOT_EDIT', 'You cannot edit your posts.
    '); -define('_MD_CAN_DELETE', 'You can delete your posts.
    '); -define('_MD_CANNOT_DELETE', 'You cannot delete your posts.
    '); -define('_MD_CAN_ADDPOLL', 'You can add new polls.
    '); -define('_MD_CANNOT_ADDPOLL', 'You cannot add new polls.
    '); -define('_MD_CAN_VOTE', 'You can vote in polls.
    '); -define('_MD_CANNOT_VOTE', 'You cannot vote in polls.
    '); -define('_MD_CAN_ATTACH', 'You can attach files to posts.
    '); -define('_MD_CANNOT_ATTACH', 'You cannot attach files to posts.
    '); -define('_MD_CAN_NOAPPROVE', 'You can post without approval.
    '); -define('_MD_CANNOT_NOAPPROVE', 'You cannot post without approval.
    '); -define('_MD_CAN_TYPE', 'You can use topic type.
    '); -define('_MD_CANNOT_TYPE', 'You cannot use topic type.
    '); -define('_MD_CAN_HTML', 'You can use HTML syntax.
    '); -define('_MD_CANNOT_HTML', 'You cannot use HTML syntax.
    '); -define('_MD_CAN_UPLOAD', 'You can upload.
    '); -define('_MD_CANNOT_UPLOAD', 'You cannot upload.
    '); -define('_MD_CAN_SIGNATURE', 'You can use signature.
    '); -define('_MD_CANNOT_SIGNATURE', 'You cannot use signature.
    '); -define('_MD_IMTOPICS', 'Important Topics'); -define('_MD_NOTIMTOPICS', 'Forum Topics'); -define('_MD_FORUMOPTION', 'Forum options'); -define('_MD_VAUP', 'View all unreplied posts'); -define('_MD_VANP', 'View all new posts'); -define('_MD_UNREPLIED', 'unreplied topics'); -define('_MD_UNREAD', 'unread topics'); -define('_MD_ALL', 'all topics'); -define('_MD_ALLPOSTS', 'all posts'); -define('_MD_VIEW', 'View'); - -//viewtopic.php -define('_MD_AUTHOR', 'Author'); -define('_MD_LOCKTOPIC', 'Lock this topic'); -define('_MD_UNLOCKTOPIC', 'Unlock this topic'); -define('_MD_UNSTICKYTOPIC', 'Make this topic UnSticky'); -define('_MD_STICKYTOPIC', 'Make this topic Sticky'); -define('_MD_DIGESTTOPIC', 'Make this topic as Digest'); -define('_MD_UNDIGESTTOPIC', 'Make this topic as UnDigest'); -define('_MD_MERGETOPIC', 'Merge this topic'); -define('_MD_MOVETOPIC', 'Move this topic'); -define('_MD_DELETETOPIC', 'Delete this topic'); -// irmtfan add restore to viewtopic -define('_MD_RESTORETOPIC', 'Restore this topic'); -define('_MD_TOP', 'Top'); -define('_MD_BOTTOM', 'Bottom'); -define('_MD_PREVTOPIC', 'Previous Topic'); -define('_MD_NEXTTOPIC', 'Next Topic'); -define('_MD_GROUP', 'Group:'); -define('_MD_QUICKREPLY', 'Quick Reply'); -define('_MD_POSTREPLY', 'Post Reply'); -define('_MD_PRINTTOPICS', 'Print Topic'); -define('_MD_PRINT', 'Print'); -define('_MD_REPORT', 'Report'); -define('_MD_PM', 'PM'); -define('_MD_EMAIL', 'Email'); -define('_MD_WWW', 'WWW'); -define('_MD_AIM', 'AIM'); -define('_MD_YIM', 'YIM'); -define('_MD_MSNM', 'MSNM'); -define('_MD_ICQ', 'ICQ'); -define('_MD_PRINT_TOPIC_LINK', 'URL for this discussion'); -define('_MD_ADDTOLIST', 'Add to your Contact List'); -define('_MD_TOPICOPT', 'Topic options'); -define('_MD_VIEWMODE', 'View mode'); -define('_MD_NEWEST', 'Newest First'); -define('_MD_OLDEST', 'Oldest First'); -define('_MD_FORUMSEARCH', 'Search Forum'); -define('_MD_RATED', 'Rated:'); -define('_MD_RATE', 'Rate Thread'); -define('_MD_RATEDESC', 'Rate this Thread'); -define('_MD_RATING', 'Vote now'); -define('_MD_RATE1', 'Terrible'); -define('_MD_RATE2', 'Bad'); -define('_MD_RATE3', 'Average'); -define('_MD_RATE4', 'Good'); -define('_MD_RATE5', 'Excellent'); -define('_MD_TOPICOPTION', 'Topic options'); -define('_MD_KARMA_REQUIREMENT', 'Your personal karma %s does not reach the required karma %s.
    Please try later.'); -define('_MD_REPLY_REQUIREMENT', 'To view this post, you must login and reply first.'); -define('_MD_TOPICOPTIONADMIN', 'Topic Admin options'); -define('_MD_POLLOPTIONADMIN', 'Poll Admin options'); -define('_MD_EDITPOLL', 'Edit this Poll'); -define('_MD_DELETEPOLL', 'Delete this Poll'); -define('_MD_RESTARTPOLL', 'Restart this Poll'); -define('_MD_ADDPOLL', 'Add Poll'); -define('_MD_QUICKREPLY_EMPTY', 'Enter a quick reply here'); -define('_MD_LEVEL', 'Level :'); -define('_MD_HP', 'HP :'); -define('_MD_MP', 'MP :'); -define('_MD_EXP', 'EXP :'); -define('_MD_BROWSING', 'Browsing this Thread:'); -define('_MD_POSTTONEWS', 'Send this post to a news Story'); -define('_MD_EXCEEDTHREADVIEW', 'Post count exceeds the threshold for thread mode
    Changing to flat mode'); - -//forumform.inc -define('_MD_QUOTE', 'Quote'); -define('_MD_VIEW_REQUIRE', 'View requirements'); -define('_MD_REQUIRE_KARMA', 'Karma'); -define('_MD_REQUIRE_REPLY', 'Reply'); -define('_MD_REQUIRE_NULL', 'No requirement'); -define('_MD_SELECT_FORMTYPE', 'Select your desired form type'); -define('_MD_FORM_COMPACT', 'Compact'); -define('_MD_FORM_DHTML', 'DHTML'); - -// ERROR messages -define('_MD_ERRORFORUM', 'ERROR: Forum not selected!'); -define('_MD_ERRORPOST', 'ERROR: Post not selected!'); -define('_MD_NORIGHTTOVIEW', 'You don\'t have the right to view this topic.'); -define('_MD_NORIGHTTOPOST', 'You don\'t have the right to post in this forum.'); -define('_MD_NORIGHTTOEDIT', 'You don\'t have the right to edit in this forum.'); -define('_MD_NORIGHTTOREPLY', 'You don\'t have the right to reply in this forum.'); -define('_MD_NORIGHTTOACCESS', 'You don\'t have the right to access this forum.'); -define('_MD_ERRORTOPIC', 'ERROR: Topic not selected!'); -define('_MD_ERRORCONNECT', 'ERROR: Could not connect to the forums database.'); -define('_MD_ERROREXIST', 'ERROR: The forum you selected does not exist. Please go back and try again.'); -define('_MD_ERROROCCURED', 'An Error Occured'); -define('_MD_COULDNOTQUERY', 'Could not query the forums database.'); -define('_MD_FORUMNOEXIST', 'Error - The forum/topic you selected does not exist. Please go back and try again.'); -define('_MD_USERNOEXIST', 'That user does not exist. Please go back and search again.'); -define('_MD_COULDNOTREMOVE', 'Error - Could not remove posts from the database!'); -define('_MD_COULDNOTREMOVETXT', 'Error - Could not remove post texts!'); -define('_MD_TIMEISUP', 'You\'ve reached the time limit for editing your post.'); -define('_MD_TIMEISUPDEL', 'You\'ve reached the time limit for deleting your post.'); - -//reply.php -define('_MD_ON', 'on');//Posted on -define('_MD_USERWROTE', '%s wrote:');// %s is username -define('_MD_RE', 'Re'); - -//post.php -define('_MD_EDITNOTALLOWED', 'You\'re not allowed to edit this post!'); -define('_MD_EDITEDBY', 'Edited by'); -define('_MD_ANONNOTALLOWED', 'Anonymous users are not allowed to post.
    Please register.'); -define('_MD_THANKSSUBMIT', 'Thanks for your submission!'); -define('_MD_REPLYPOSTED', 'A reply to your topic has been posted.'); -define('_MD_HELLO', 'Hello %s,'); -define('_MD_URRECEIVING', 'You are receiving this email because a message you posted on %s forums has been replied to.');// %s is your site name -define('_MD_CLICKBELOW', 'Click on the link below to view the thread:'); -define('_MD_WAITFORAPPROVAL', 'Thank you. Your post will be approved before publication.'); -define('_MD_POSTING_LIMITED', 'Why not take a break and come back in %d sec'); - -//forumform.inc -define('_MD_NAMEMAIL', 'Name/Email:'); -define('_MD_LOGOUT', 'Logout'); -define('_MD_REGISTER', 'Register'); -define('_MD_SUBJECTC', 'Subject:'); -define('_MD_MESSAGEICON', 'Message Icon:'); -define('_MD_MESSAGEC', 'Message:'); -define('_MD_ALLOWEDHTML', 'Allowed HTML:'); -define('_MD_OPTIONS', 'Options:'); -define('_MD_POSTANONLY', 'Post Anonymously'); -define('_MD_DOSMILEY', 'Enable Smiley'); -define('_MD_DOXCODE', 'Enable Xoops Code'); -define('_MD_DOBR', 'Enable line break (Suggest to turn off if HTML enabled)'); -define('_MD_DOHTML', 'Enable html tags'); -define('_MD_NEWPOSTNOTIFY', 'Notify me of new posts in this thread'); -define('_MD_ATTACHSIG', 'Attach Signature'); -define('_MD_POST', 'Post'); -define('_MD_SUBMIT', 'Submit'); -define('_MD_CANCELPOST', 'Cancel Post'); -define('_MD_REMOVE', 'Remove'); -define('_MD_UPLOAD', 'Upload'); - -// forumuserpost.php -define('_MD_ADD', 'Add'); -define('_MD_REPLY', 'Reply'); - -// topicmanager.php -define('_MD_VIEWTHETOPIC', 'View the topic'); -define('_MD_RETURNTOTHEFORUM', 'Return to the forum'); -define('_MD_RETURNFORUMINDEX', 'Return to the forum index'); -define('_MD_ERROR_BACK', 'Error - Please go back and try again.'); -define('_MD_GOTONEWFORUM', 'View the updated topic'); -define('_MD_TOPICDELETE', 'The topic has been deleted.'); -// irmtfan add restore to viewtopic -define('_MD_TOPICRESTORE', 'The topic has been restored.'); -define('_MD_TOPICMERGE', 'The topic has been merged.'); -define('_MD_TOPICMOVE', 'The topic has been moved.'); -define('_MD_TOPICLOCK', 'The topic has been locked.'); -define('_MD_TOPICUNLOCK', 'The topic has been unlocked.'); -define('_MD_TOPICSTICKY', 'The topic has been Stickyed.'); -define('_MD_TOPICUNSTICKY', 'The topic has been unStickyed.'); -define('_MD_TOPICDIGEST', 'The topic has been Digested.'); -define('_MD_TOPICUNDIGEST', 'The topic has been unDigested.'); -define('_MD_DELETE', 'Delete'); -define('_MD_MOVE', 'Move'); -define('_MD_MERGE', 'Merge'); -define('_MD_LOCK', 'Lock'); -define('_MD_UNLOCK', 'unLock'); -define('_MD_STICKY', 'Sticky'); -define('_MD_UNSTICKY', 'unSticky'); -define('_MD_DIGEST', 'Digest'); -define('_MD_UNDIGEST', 'unDigest'); -define('_MD_DESC_DELETE', 'Once you press the delete button at the bottom of this form the topic you have selected, and all its related posts, will be permanently removed.'); -// irmtfan add restore to viewtopic -define('_MD_DESC_RESTORE', 'Once you press the restore button at the bottom of this form the topic you have selected, and all its related posts, will be restored.'); -define('_MD_DESC_MOVE', 'Once you press the move button at the bottom of this form the topic you have selected, and its related posts, will be moved to the forum you have selected.'); -define('_MD_DESC_MERGE', - 'Once you press the merge button at the bottom of this form the topic you have selected, and its related posts, will be merged to the topic you have selected.
    The destination topic ID must be smaller than current one.'); -define('_MD_DESC_LOCK', 'Once you press the lock button at the bottom of this form the topic you have selected will be locked. You may unlock it at a later time if you like.'); -define('_MD_DESC_UNLOCK', 'Once you press the unlock button at the bottom of this form the topic you have selected will be unlocked. You may lock it again at a later time if you like.'); -define('_MD_DESC_STICKY', 'Once you press the Sticky button at the bottom of this form the topic you have selected will be Stickyed. You may unSticky it again at a later time if you like.'); -define('_MD_DESC_UNSTICKY', 'Once you press the unSticky button at the bottom of this form the topic you have selected will be unStickyed. You may Sticky it again at a later time if you like.'); -define('_MD_DESC_DIGEST', 'Once you press the Digest button at the bottom of this form the topic you have selected will be Digested. You may unDigest it again at a later time if you like.'); -define('_MD_DESC_UNDIGEST', 'Once you press the unDigest button at the bottom of this form the topic you have selected will be unDigested. You may Digest it again at a later time if you like.'); -define('_MD_MERGETOPICTO', 'Merge Topic To:'); -define('_MD_MOVETOPICTO', 'Move Topic To:'); -define('_MD_NOFORUMINDB', 'No Forums in DB'); - -// delete.php -define('_MD_DELNOTALLOWED', 'Sorry, but you\'re not allowed to delete this post.'); -define('_MD_AREUSUREDEL', 'Are you sure you want to delete this post and all its child posts?'); -define('_MD_POSTSDELETED', 'Selected post and all its child posts deleted.'); -define('_MD_POSTDELETED', 'Selected post deleted.'); -define('_MD_POSTFIRSTWITHREPLYNODELETED', 'The start posting can not be deleted if there are already answers
    do this, delete the whole topic.'); - -// definitions moved from global. -define('_MD_THREAD', 'Thread'); -define('_MD_FROM', 'From'); -define('_MD_JOINED', 'Joined'); -define('_MD_ONLINE', 'Online'); -define('_MD_OFFLINE', 'Offline'); -define('_MD_FLAT', 'Flat'); - -// online.php -define('_MD_USERS_ONLINE', 'Users Online:'); -define('_MD_ANONYMOUS_USERS', 'Anonymous Users'); -define('_MD_REGISTERED_USERS', 'Registered Users: '); -define('_MD_BROWSING_FORUM', 'Users browsing forum'); -define('_MD_TOTAL_ONLINE', 'Total %d Users Online.'); -define('_MD_ADMINISTRATOR', 'Administrator'); -define('_MD_NO_SUCH_FILE', 'File not exist!'); -//define('_MD_ERROR_UPATEATTACHMENT', 'Error occur when updating attachment'); - -// ratethread.php -define('_MD_CANTVOTEOWN', 'You cannot vote on the topic you submitted.
    All votes are logged and reviewed.'); -define('_MD_VOTEONCE', 'Please do not vote for the same topic more than once.'); -define('_MD_VOTEAPPRE', 'Your vote is appreciated.'); -define('_MD_THANKYOU', 'Thank you for taking the time to vote here at %s');// %s is your site name -define('_MD_VOTES', 'Votes'); -define('_MD_NOVOTERATE', 'You did not rate this Topic'); - -// polls.php -define('_MD_POLL_DBUPDATED', 'Database Updated Successfully!'); -define('_MD_POLL_POLLCONF', 'Polls Configuration'); -define('_MD_POLL_POLLSLIST', 'Polls List'); -define('_MD_POLL_AUTHOR', 'Author of this poll'); -define('_MD_POLL_DISPLAYBLOCK', 'Display in block?'); -define('_MD_POLL_POLLQUESTION', 'Poll Question'); -define('_MD_POLL_VOTERS', 'Total voters'); -define('_MD_POLL_VOTES', 'Total votes'); -define('_MD_POLL_EXPIRATION', 'Expiration'); -define('_MD_POLL_EXPIRED', 'Expired'); -define('_MD_POLL_VIEWLOG', 'View log'); -define('_MD_POLL_CREATNEWPOLL', 'Create new poll'); -define('_MD_POLL_POLLDESC', 'Poll description'); -define('_MD_POLL_DISPLAYORDER', 'Display order'); -define('_MD_POLL_ALLOWMULTI', 'Allow multiple selections?'); -define('_MD_POLL_NOTIFY', 'Notify the poll author when expired?'); -define('_MD_POLL_POLLOPTIONS', 'Options'); -define('_MD_POLL_EDITPOLL', 'Edit poll'); -define('_MD_POLL_FORMAT', 'Format: yyyy-mm-dd hh:mm:ss'); -define('_MD_POLL_CURRENTTIME', 'Current time is %s'); -define('_MD_POLL_EXPIREDAT', 'Expired at %s'); -define('_MD_POLL_RESTART', 'Restart this poll'); -define('_MD_POLL_ADDMORE', 'Add more options'); -define('_MD_POLL_RUSUREDEL', 'Are you sure you want to delete this poll and all its comments?'); -define('_MD_POLL_RESTARTPOLL', 'Restart poll'); -define('_MD_POLL_RESET', 'Reset all logs for this poll?'); -define('_MD_POLL_ADDPOLL', 'Add Poll'); -define('_MD_POLLMODULE_ERROR', 'Poll module not available for use'); -define('_MD_VIEW_LOG', 'View Log'); -define('_MD_LOG_NOT_IMPLEMENTED', 'Sorry, not yet'); -define('_MD_LOG_XOOPSPOLL_ADMIN_REDIRECT', 'Redirecting to Xoopspoll Administration'); - -//report.php -define('_MD_REPORTED', 'Thank you for reporting this post/thread! A moderator will look into your report shortly.'); -define('_MD_REPORT_ERROR', 'Error occurred while sending the report.'); -define('_MD_REPORT_TEXT', 'Report message:'); -define('_MD_PDF', 'Create PDF from Post'); -define('_MD_PDF_PAGE', 'Page %s'); - -//print.php -define('_MD_COMEFROM', 'This Post was from:'); - -//viewpost.php -define('_MD_VIEWALLPOSTS', 'All Posts'); -define('_MD_VIEWTOPIC', 'Topic'); -define('_MD_VIEWFORUM', 'Forum'); -define('_MD_COMPACT', 'Compact'); -define('_MD_MENU_SELECT', 'Selection'); -define('_MD_MENU_HOVER', 'Hover'); -define('_MD_MENU_CLICK', 'Click'); -define('_MD_WELCOME_SUBJECT', '%s has joined the forum'); -define('_MD_WELCOME_MESSAGE', 'Hi, %s has joined you. Let\'s start ...'); -define('_MD_VIEWNEWPOSTS', 'View new posts'); -define('_MD_INVALID_SUBMIT', 'Invalid submission. You could have exceeded session time. Please re-submit or make a backup of your post and login to resubmit if necessary.'); -define('_MD_ACCOUNT', 'Account'); -define('_MD_NAME', 'Name'); -define('_MD_PASSWORD', 'Password'); -define('_MD_LOGIN', 'Login'); -define('_MD_APPROVE', 'Approve'); -define('_MD_RESTORE', 'Restore'); -define('_MD_SPLIT_ONE', 'Split'); -define('_MD_SPLIT_TREE', 'Split all children'); -define('_MD_SPLIT_ALL', 'Split all'); -define('_MD_TYPE_ADMIN', 'Admin mode'); -define('_MD_TYPE_VIEW', 'View mode'); -define('_MD_TYPE_PENDING', 'Pending'); -define('_MD_TYPE_DELETED', 'Deleted'); -define('_MD_TYPE_SUSPEND', 'Suspension'); -define('_MD_DBUPDATED', 'Database Updated Successfully!'); -define('_MD_SUSPEND_SUBJECT', 'User %s is suspended for %d days'); -define('_MD_SUSPEND_TEXT', 'User %s is suspended for %d days due to:
    [quote]%s[/quote]

    The suspension is valid till %s'); -define('_MD_SUSPEND_UID', 'User ID'); -define('_MD_SUSPEND_IP', 'IP suspended (full or partial)'); -define('_MD_SUSPEND_DURATION', 'Suspension duration (Days)'); -define('_MD_SUSPEND_DESC', 'Suspension reason'); -define('_MD_SUSPEND_LIST', 'Suspension list'); -define('_MD_SUSPEND_START', 'Start'); -define('_MD_SUSPEND_EXPIRE', 'End'); -define('_MD_SUSPEND_SCOPE', 'Scope'); -define('_MD_SUSPEND_MANAGEMENT', 'Moderation management'); -define('_MD_SUSPEND_NOACCESS', 'Your ID or IP has been suspended'); -define('_MD_NEWBB_TYPE', 'Topic type'); -define('_MD_NEWBB_SEENOTGUEST', "Link only for registered users"); -define('_MD_NEWBB_REPORTSUBJECT', 'A contribution has been reported'); -define('_MD_NEWBB_GOTOLASTPOST', 'Go to last post'); -define('_MD_EDITEDMSG', 'Reason:'); -define('_MD_DELEDEDMSG', 'Reason for deleting
    (If a reason is provided, the user will receive a message):'); -define('_MD_DELEDEDMSG_SUBJECT', 'Deletion of your article'); -define('_MD_DELEDEDMSG_BODY', 'Hello %s, -your post in the forum - -%s -was deleted by me -As justification, I am taking the following information on: - -%s - -With best greetings -%s -------------------------- -Please do not reply to this message! -%s -%s'); -define('_MD_FORUMHOME', 'Board index'); -define('_MD_NEWBB_SEEWAITREPORT', "There were %s Contributions reported "); -define('NEWBB_PDF_SUBJECT', 'Title: '); -define('NEWBB_PDF_TOPIC', 'Post: '); -define('NEWBB_PDF_AUTHOR', 'Author: '); -define('NEWBB_PDF_DATE', 'Date: '); -define('NEWBB_PDF_URL', 'Link to Post: '); -define('_NW_PAGE', 'Site: '); -define('_AM_NEWBB_NOTOPIC', 'No Posts'); -define('_MD_NORSS_DATA', 'No data to display'); -define('_MD_NEWBB_STATS', 'Statistics'); -define('_MD_POSTTIME', 'posted on'); - -// 4.2 -define('_MD_ADVERTISING_BLOCK', '
    You could place your Ad here!
    Please contact us to learn more about it.'); -define('_MD_ADVERTISING_USER', 'Advertisement'); -define('_MD_SHARE_FACEBOOK', 'Facebook'); -define('_MD_SHARE_TWITTER', 'Twitter'); -define('_MD_SHARE_GOOGLEPLUS', 'Google Plus'); -define('_MD_SHARE_LINKEDIN', 'Linkedin'); -define('_MD_SHARE_STUMBLEUPON', 'Stumbleupon'); -define('_MD_SHARE_FRIENDFEED', 'FriendFeed'); -define('_MD_SHARE_REDDIT', 'Reddit'); -define('_MD_SHARE_DELICIOUS', 'Del.icio.us'); -define('_MD_SHARE_DIGG', 'Digg'); -define('_MD_SHARE_TECHNORATI', 'Technorati'); -define('_MD_SHARE_MRWONG', 'Mr. Wong'); - -//4.3 -define('_MD_GO', 'Go'); -define('_MD_NEWBB_SEEUSERDATA', 'See User information'); -define('_MD_NEWBB_MAXKB', 'File is too big (max %s Kb possible).'); -define('_MD_NEWBB_UPLOAD_ERRNODEF', 'undefined Error'); -define('_MD_NEWBB_MAXUPLOADFILEINI', 'The uploaded file exceeds the upload_max_filesize directive in php.ini.'); -define('_MD_NEWBB_MAXPIC', 'Images at the max. Size %s X %s pixels.'); -define('_MD_NEWBB_SEARCHDISABLED', 'The search is disabled and can not be used.'); -// irmtfan added messages -define('_MD_NEWBB_HIDEUSERDATA', 'Hide User information'); -define('_MD_NEWBB_HIDE', 'Hide'); -define('_MD_NEWBB_SEE', 'See'); -// votepolls.php - irmtfan -define('_MD_POLL_NOOPTION', 'You must choose an option !!'); -define('_MD_SEARCHTOPIC', 'Search Topic'); -define('_MD_SHOWSEARCH', 'Show results:'); -define('_MD_SEARCHPOSTTEXT', 'Posts text'); -define('_MD_SELECT_STARTLAG', 'Start lag of selected text'); -define('_MD_SELECT_STARTLAG_DESC', 'Select text from X characters before the first keyword'); -define('_MD_SELECT_LENGTH', 'Length of selected text'); -define('_MD_SELECT_HTML', 'Strip all html from result?'); -define('_MD_SELECT_EXCLUDE', 'Exclude these tags:'); -define('_MD_SELECT_TAG', 'Tag'); - -define('_MD_CAN_PDF', 'You can create pdf.
    '); -define('_MD_CANNOT_PDF', 'You cannot create pdf.
    '); -define('_MD_CAN_PRINT', 'You can get print page.
    '); -define('_MD_CANNOT_PRINT', 'You cannot get print page.
    '); -define('_MD_NORIGHTTOPDF', 'You don\'t have the right to create pdf in this forum.'); -define('_MD_NORIGHTTOPRINT', 'You don\'t have the right to get print in this forum.'); - -// irmtfan for new block system -define('_MD_TOPICHASNOTPOLL', 'Topic has no poll'); -define('_MD_VOTED', 'Voted topics'); -define('_MD_UNVOTED', 'Unvoted topics'); -define('_MD_VIEWED', 'Viewed topics'); -define('_MD_UNVIEWED', 'Unviewed topics'); -define('_MD_REPLIED', 'Replied topics'); -define('_MD_READ', 'Read topics'); -define('_MD_POLL_POLL', 'Poll'); -define('_MD_PAGENAV_DISPLAY', 'Display of navigation'); - -// !!IMPORTANT!! insert '\' before any char among reserved chars: 'a', 'A', 'B', 'c', 'd', 'D', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'l', 'L', 'm', 'M', 'n', 'O', 'r', 's', 'S', 't', 'T', 'U', 'w', 'W', 'Y', 'y', 'z', 'Z' -// insert double '\' before 't', 'r', 'n' -define('_MD_TODAY', '\T\o\d\a\y G:i:s'); -define('_MD_YESTERDAY', '\Y\e\s\\t\e\\r\d\a\y G:i:s'); -define('_MD_MONTHDAY', 'n/j G:i:s'); -define('_MD_YEARMONTHDAY', 'Y/n/j G:i'); diff --git a/extras/newbb_4x/irmtfan/language/index.html b/extras/newbb_4x/irmtfan/language/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/language/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/polls.php b/extras/newbb_4x/irmtfan/polls.php deleted file mode 100644 index 73994d5..0000000 --- a/extras/newbb_4x/irmtfan/polls.php +++ /dev/null @@ -1,808 +0,0 @@ - - */ - -include_once __DIR__ . '/header.php'; - -include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); -include_once $GLOBALS['xoops']->path('class/xoopslists.php'); -include_once $GLOBALS['xoops']->path('class/xoopsblock.php'); -xoops_load('XoopsRequest'); - -// irmtfan correct the way and typo=addmor -> addmore -$op = 'add'; -$goodOps = [ - 'add', - 'save', - 'edit', - 'update', - 'addmore', - 'savemore', - 'delete', - 'delete_ok', - 'restart', - 'restart_ok', - 'log' -]; -$op = XoopsRequest::getString('op', 'add'); -$op = (!in_array($op, $goodOps)) ? 'add' : $op; - -//$poll_id = (isset($_GET['poll_id'])) ? (int)($_GET['poll_id']) : 0; -//$poll_id = (isset($_POST['poll_id'])) ? (int)($_POST['poll_id']) : $poll_id; -$poll_id = XoopsRequest::getInt('poll_id', XoopsRequest::getInt('poll_id', 0, 'POST'), 'GET'); -//$topic_id = (isset($_GET['topic_id'])) ? (int)($_GET['topic_id']) : 0; -//$topic_id = (isset($_POST['topic_id'])) ? (int)($_POST['topic_id']) : $topic_id; -$topic_id = XoopsRequest::getInt('topic_id', XoopsRequest::getInt('topic_id', 0, 'POST'), 'GET'); - -/** {@internal $pollmodules is initialized in ./header.php file} */ -if ('xoopspoll' === $pollmodules) { - xoops_load('constants', 'xoopspoll'); - xoops_load('pollUtility', 'xoopspoll'); - xoops_load('XoopsRequest'); - xoops_loadLanguage('admin', 'xoopspoll'); - $xpPollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); -} else { - //is this umfrage? - if ('umfrage' === $pollmodules) { - include $GLOBALS['xoops']->path('modules/umfrage/include/constants.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrage.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrageoption.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragelog.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragerenderer.php'); - } else { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_POLLMODULE_ERROR); - } -} -/** @var NewbbTopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); -$topic_obj = $topicHandler->get($topic_id); -if ($topic_obj instanceof \Topic) { - $forum_id = $topic_obj->getVar('forum_id'); -} else { - redirect_header('index.php', 2, _MD_POLLMODULE_ERROR . ': ' . _MD_FORUMNOEXIST); -} - -/** @var NewbbForumHandler $forumHandler */ -$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); -$forum_obj = $forumHandler->get($forum_id); -if (!$forumHandler->getPermission($forum_obj)) { - redirect_header('index.php', 2, _MD_NORIGHTTOACCESS); -} - -if (!$topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'view')) { - redirect_header('viewforum.php?forum=' . $forum_obj->getVar('forum_id'), 2, _MD_NORIGHTTOVIEW); -} - -include $GLOBALS['xoops']->path('header.php'); - -if (!newbb_isAdmin($forum_obj)) { - $perm = false; - if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'addpoll') - //&& $forum_obj->getVar('allow_polls') == 1 { - ) { - if (('add' === $op || 'save' === $op || 'update' === $op) - && !$topic_obj->getVar('topic_haspoll') - && ($GLOBALS['xoopsUser'] instanceof XoopsUser) - && ($GLOBALS['xoopsUser']->getVar('uid') === $topic_obj->getVar('topic_poster')) - ) { - $perm = true; - } elseif (!empty($poll_id) && ($GLOBALS['xoopsUser'] instanceof XoopsUser)) { - if ('xoopspoll' === $pollmodules) { - $poll_obj = $xpPollHandler->get($poll_id); - } else { //Umfrage - $poll_obj = new \Umfrage($poll_id); - } - if ($GLOBALS['xoopsUser']->getVar('uid') === $poll_obj->getVar('user_id')) { - $perm = true; - } - unset($poll_obj); - } - } - if (!$perm) { - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _NOPERM); - } -} - -switch ($op) { - /* - case "add": - if ("xoopspoll" == $pollmodules) { - echo "

    " . _AM_XOOPSPOLL_POLLCONF . "

    \n"; - $poll_obj = $xpPollHandler->get($poll_id); - $poll_obj->renderForm($_SERVER['PHP_SELF'], 'post', array("topic_id" => $topic_id)); - } else { // Umfrage - $poll_form = new XoopsThemeForm(_MD_POLL_CREATNEWPOLL, "poll_form", "polls.php", "post", true); - - $question_text = new XoopsFormText(_MD_POLL_POLLQUESTION, "question", 50, 255); - $poll_form->addElement($question_text, true); - - $desc_tarea = new XoopsFormTextarea(_MD_POLL_POLLDESC, "description"); - $poll_form->addElement($desc_tarea); - - // $currenttime = formatTimestamp(time(), "Y-m-d H:i:s"); - // $endtime = formatTimestamp(time() + 604800, "Y-m-d H:i:s"); - $currenttime = formatTimestamp(time(), _DATESTRING); - $endtime = formatTimestamp(time() + (86400 * 10), _DATESTRING); - - $expire_text = new XoopsFormText(_MD_POLL_EXPIRATION . "
    " . _MD_POLL_FORMAT . "
    " . sprintf(_MD_POLL_CURRENTTIME, $currenttime) . "
    ", "end_time", 30, 19, $endtime); - $poll_form->addElement($expire_text); - - $weight_text = new XoopsFormText(_MD_POLL_DISPLAYORDER, "weight", 6, 5, 0); - $poll_form->addElement($weight_text); - - $multi_yn = new XoopsFormRadioYN(_MD_POLL_ALLOWMULTI, "multiple", 0); - $poll_form->addElement($multi_yn); - - $notify_yn = new XoopsFormRadioYN(_MD_POLL_NOTIFY, "notify", 1); - $poll_form->addElement($notify_yn); - - $option_tray = new XoopsFormElementTray(_MD_POLL_POLLOPTIONS, ""); - $barcolor_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . "/modules/{$pollmodules}/assets/images/colorbars/"); - for ($i = 0; $i < 10; ++$i) { - $current_bar = ("blank.gif" != current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); - $option_text = new XoopsFormText("", "option_text[]", 50, 255); - $option_tray->addElement($option_text); - $color_select = new XoopsFormSelect("", "option_color[{$i}]", $current_bar); - $color_select->addOptionArray($barcolor_array); - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$pollmodules}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); - $color_label = new XoopsFormLabel("", "
    "); - $option_tray->addElement($color_select); - $option_tray->addElement($color_label); - if (!next($barcolor_array)) { - reset($barcolor_array); - } - unset($color_select, $color_label); - } - $poll_form->addElement($option_tray); - $poll_form->addElement(new XoopsFormButton("", "poll_submit", _SUBMIT, "submit")); - $poll_form->addElement(new XoopsFormHidden("op", "save")); - $poll_form->addElement(new XoopsFormHidden("topic_id", $topic_id)); - - echo "

    " . _MD_POLL_POLLCONF . "

    \n"; - $poll_form->display(); - } - break; - - case "save": - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - - // make sure the question isn't empty - if (empty($_POST['question'])) { - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLQUESTION . ' !'); - } - - // Check to see if any options are set - $option_text = isset($_POST['option_text']) ? $_POST['option_text'] : ""; - $option_string = is_array($option_text) ? implode("", $option_text) : $option_text; - $option_string = trim($option_string); - if (empty($option_string)) { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLOPTIONS . ' !'); - } - - if ("xoopspoll" == $pollmodules) { - // $poll_obj = $xpPollHandler->create(); - $poll_obj = $xpPollHandler->get($poll_id); // will either get or create poll obj - $default_poll_duration = XoopspollConstants::DEFAULT_POLL_DURATION; - $poll_not_mailed = XoopspollConstants::POLL_NOT_MAILED; - $poll_mailed = XoopspollConstants::POLL_MAILED; - $display = XoopspollConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK; - } else { // Umfrage - // $poll_obj = new Umfrage(); - if (empty($poll_id)) { //if creating new poll - $poll_obj = new Umfrage(); - } else { // updating current poll - $poll_obj = new Umfrage($poll_id); - } - $default_poll_duration = (86400 * 10); - $poll_not_mailed = POLL_NOTMAILED; - $poll_mailed = POLL_MAILED; - $display = 0; - } - - $poll_obj->setVar("question", $_POST['question']); - $description = (isset($_POST['description'])) ? htmlspecialchars($_POST['description']) : ''; - $poll_obj->setVar("description", $description); - - if (!empty($_POST['end_time'])) { - $timezone = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar("timezone") : null; - //$poll_obj->setVar("end_time", userTimeToServerTime(strtotime($_POST['end_time']), $timezone)); - //Hack by irmtfan - $poll_obj->setVar("end_time", userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($_POST['end_time']) : strtotime($_POST['end_time']), $timezone)); - } else { - // if expiration date is not set, set it - $poll_obj->setVar("end_time", time() + $default_poll_duration); - } - - $weight = isset($_POST['weight']) ? (int)($_POST['weight']) : 0; - $multiple = isset($_POST['multiple']) ? (int)($_POST['multiple']) : 0; - $notify = (!empty($_POST["notify"])) ? $poll_not_mailed : $poll_mailed; - $uid = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar("uid") : 0; - - $poll_obj->setVar("display", $display); - $poll_obj->setVar("weight", $weight); - $poll_obj->setVar("multiple", $multiple); - $poll_obj->setVar("mail_status", $notify); - $poll_obj->setVar("user_id", $uid); - - if ('xoopspoll' == $pollmodules) { - $poll_obj = $xpPollHandler->insert($poll_obj); - $new_poll_id = ($poll_obj instanceof XoopspollPoll) ? $poll_obj->getVar('poll_id') : null; - } else { // Umfrage - $new_poll_id = $poll_obj->store(); - } - $option_color = empty($_POST['option_color']) ? null : $_POST['option_color']; - if (!empty($new_poll_id)) { - $i = 0; - foreach ($option_text as $optxt) { - $optxt = trim($optxt); - if ("" != $optxt) { - if ('xoopspoll' == $pollmodules) { - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $option = $xpOptHandler->create(); - $option->setVar("option_text", $optxt); - $option->setVar("option_color", $option_color[$i]); - $option->setVar("poll_id", $new_poll_id); - $xpOptHandler->insert($option); - } else { // Umfrage - $option = new UmfrageOption(); - $option->setVar("option_text", $optxt); - $option->setVar("option_color", $option_color[$i]); - $option->setVar("poll_id", $new_poll_id); - $option->store(); - } - } - ++$i; - } - // update topic to indicate it has a poll - $topic_obj->setVar('topic_haspoll', 1); - $topic_obj->setVar('poll_id', $new_poll_id); - $success = $topicHandler->insert($topic_obj); - if (!$success) { - xoops_error($topicHandler->getHtmlErrors()); - } - - // $sql = "UPDATE " . $GLOBALS['xoopsDB']->prefix("bb_topics") . " SET topic_haspoll = 1, poll_id = {$new_poll_id} WHERE topic_id = {$topic_id}"; - // if (!$result = $GLOBALS['xoopsDB']->query($sql) ) { - // xoops_error($GLOBALS['xoopsDB']->error()); - } - - include_once $GLOBALS['xoops']->path("class/template.php"); - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - } else { - xoops_error($poll_obj->getHtmlErrors()); - exit(); - } - // irmtfan full URL - redirect_header($GLOBALS['xoops']->url("modules/".$xoopsModule->getVar("dirname")."/viewtopic.php?topic_id={$topic_id}"), 1, _MD_POLL_DBUPDATED); - break; - */ - case 'add': - case 'edit': - if ('xoopspoll' === $pollmodules) { - echo '

    ' . _MD_POLL_EDITPOLL . "

    \n"; - $poll_obj = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist - $poll_obj->renderForm($_SERVER['PHP_SELF'], 'post', ['topic_id' => $topic_id]); - } else { // Umfrage - if (empty($poll_id)) { - $poll_obj = new \Umfrage(); - } else { - $poll_obj = new \Umfrage($poll_id); - } - $poll_form = new XoopsThemeForm(_MD_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true); - $author_label = new XoopsFormLabel(_MD_POLL_AUTHOR, - "" . newbb_getUnameFromId($poll_obj->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . ''); - $poll_form->addElement($author_label); - $question_text = new XoopsFormText(_MD_POLL_POLLQUESTION, 'question', 50, 255, $poll_obj->getVar('question', 'E')); - $poll_form->addElement($question_text); - $desc_tarea = new XoopsFormTextarea(_MD_POLL_POLLDESC, 'description', $poll_obj->getVar('description', 'E')); - $poll_form->addElement($desc_tarea); - // $date = formatTimestamp($poll_obj->getVar("end_time"), "Y-m-d H:i:s"); - $date = formatTimestamp($poll_obj->getVar('end_time'), _DATESTRING); - if (!$poll_obj->hasExpired()) { - $expire_text = new XoopsFormText(_MD_POLL_EXPIRATION . '
    ' . _MD_POLL_FORMAT . '
    ' . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '
    ', 'end_time', 20, 19, $date); - $poll_form->addElement($expire_text); - } else { - // irmtfan full URL - add topic_id - $restart_label = new XoopsFormLabel(_MD_POLL_EXPIRATION, - sprintf(_MD_POLL_EXPIREDAT, $date) . "
    getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" - . _MD_POLL_RESTART . ''); - $poll_form->addElement($restart_label); - } - $weight_text = new XoopsFormText(_MD_POLL_DISPLAYORDER, 'weight', 6, 5, $poll_obj->getVar('weight')); - $poll_form->addElement($weight_text); - $multi_yn = new XoopsFormRadioYN(_MD_POLL_ALLOWMULTI, 'multiple', $poll_obj->getVar('multiple')); - $poll_form->addElement($multi_yn); - $options_arr =& \UmfrageOption::getAllByPollId($poll_id); - $notify_value = 1; - if (0 !== $poll_obj->getVar('mail_status')) { - $notify_value = 0; - } - $notify_yn = new XoopsFormRadioYN(_MD_POLL_NOTIFY, 'notify', $notify_value); - $poll_form->addElement($notify_yn); - $option_tray = new XoopsFormElementTray(_MD_POLL_POLLOPTIONS, ''); - $barcolor_array = XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$pollmodules}/assets/images/colorbars/")); - $i = 0; - foreach ($options_arr as $option) { - $option_tray->addElement(new XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text'))); - $option_tray->addElement(new XoopsFormHidden('option_id[]', $option->getVar('option_id'))); - $color_select = new XoopsFormSelect('', "option_color[{$i}]", $option->getVar('option_color')); - $color_select->addOptionArray($barcolor_array); - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$pollmodules}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); - $color_label = new XoopsFormLabel('', "url("modules/{$pollmodules}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' />
    "); - $option_tray->addElement($color_select); - $option_tray->addElement($color_label); - unset($color_select, $color_label); - ++$i; - } - // irmtfan full URL - $more_label = new XoopsFormLabel('', "
    getVar('dirname') . "/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_POLL_ADDMORE . ''); - $option_tray->addElement($more_label); - $poll_form->addElement($option_tray); - $poll_form->addElement(new XoopsFormHidden('op', 'update')); - $poll_form->addElement(new XoopsFormHidden('topic_id', $topic_id)); - $poll_form->addElement(new XoopsFormHidden('poll_id', $poll_id)); - // $poll_form->addElement(new XoopsFormButton("", "poll_submit", _SUBMIT, "submit")); - $poll_form->addElement(new XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); - - echo '

    ' . _MD_POLL_POLLCONF . "

    \n"; - $poll_form->display(); - } - break; - - case 'save': - case 'update': - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - - /* make sure there's at least one option */ - $option_text = XoopsRequest::getString('option_text', '', 'POST'); - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; - $option_string = trim($option_string); - if (empty($option_string)) { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLOPTIONS . ' !'); - } - - if ('xoopspoll' === $pollmodules) { - $poll_obj = $xpPollHandler->get($poll_id); - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - - $notify = XoopsRequest::getInt('notify', XoopspollConstants::NOTIFICATION_ENABLED, 'POST'); - - $currentTimestamp = time(); - $xuEndTimestamp = strtotime(XoopsRequest::getString('xu_end_time', null, 'POST')); - $endTimestamp = empty($xuEndTimestamp) ? ($currentTimestamp + XoopspollConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); - $xuStartTimestamp = strtotime(XoopsRequest::getString('xu_start_time', null, 'POST')); - $startTimestamp = empty($xuStartTimestamp) ? ($endTimestamp - XoopspollConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); - - // don't allow changing start time if there are votes in the log - if (($startTimestamp < $poll_obj->getVar('start_time')) - && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0) - ) { - $startTimestamp = $poll_obj->getVar('start_time'); //don't change start time - } - - $poll_vars = [ - 'user_id' => XoopsRequest::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), - 'question' => XoopsRequest::getString('question', null, 'POST'), - 'description' => XoopsRequest::getText('description', null, 'POST'), - 'mail_status' => (XoopspollConstants::NOTIFICATION_ENABLED === $notify) ? XoopspollConstants::POLL_NOT_MAILED : XoopspollConstants::POLL_MAILED, - 'mail_voter' => XoopsRequest::getInt('mail_voter', XoopspollConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), - 'start_time' => $startTimestamp, - 'end_time' => $endTimestamp, - 'display' => XoopsRequest::getInt('display', XoopspollConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), - 'visibility' => XoopsRequest::getInt('visibility', XoopspollConstants::HIDE_NEVER, 'POST'), - 'weight' => XoopsRequest::getInt('weight', XoopspollConstants::DEFAULT_WEIGHT, 'POST'), - 'multiple' => XoopsRequest::getInt('multiple', XoopspollConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), - 'multilimit' => XoopsRequest::getInt('multilimit', XoopspollConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), - 'anonymous' => XoopsRequest::getInt('anonymous', XoopspollConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST') - ]; - $poll_obj->setVars($poll_vars); - $poll_id = $xpPollHandler->insert($poll_obj); - if (!$poll_id) { - $err = $poll_obj->getHtmlErrors(); - exit($err); - } - - // now get the options - $optionIdArray = XoopsRequest::getArray('option_id', [], 'POST'); - $optionIdArray = array_map('\intval', $optionIdArray); - $optionTextArray = XoopsRequest::getArray('option_text', [], 'POST'); - $optionColorArray = XoopsRequest::getArray('option_color', [], 'POST'); - - foreach ($optionIdArray as $key => $oId) { - if (!empty($oId) && ($option_obj = $xpOptHandler->get($oId))) { - // existing option object so need to update it - $optionTextArray[$key] = trim($optionTextArray[$key]); - if ('' === $optionTextArray[$key]) { - // want to delete this option - if (false !== $xpOptHandler->delete($option_obj)) { - // now remove it from the log - $xpLogHandler->deleteByOptionId($option_obj->getVar('option_id')); - //update vote count in poll - $xpPollHandler->updateCount($poll_obj); - } else { - xoops_error($xpLogHandler->getHtmlErrors()); - break; - } - } else { - $option_obj->setVar('option_text', $optionTextArray[$key]); - $option_obj->setVar('option_color', $optionColorArray[$key]); - $option_obj->setVar('poll_id', $poll_id); - $xpOptHandler->insert($option_obj); - } - } else { - // new option object - $option_obj = $xpOptHandler->create(); - $optionTextArray[$key] = trim($optionTextArray[$key]); - if ('' !== $optionTextArray[$key]) { // ignore if text is empty - $option_obj->setVar('option_text', $optionTextArray[$key]); - $option_obj->setVar('option_color', $optionColorArray[$key]); - $option_obj->setVar('poll_id', $poll_id); - $xpOptHandler->insert($option_obj); - } - unset($option_obj); - } - } - - // clear the template cache so changes take effect immediately - // include_once $GLOBALS['xoops']->path("class" . "/template.php"); - // xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); - // xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - // redirect_header("viewtopic.php?topic_id={$topic_id}", XoopspollConstants::REDIRECT_DELAY_SHORT, _MD_POLL_DBUPDATED); - } else { // Umfrage - $poll_obj = new \Umfrage($poll_id); - $poll_obj->setVar('question', @$_POST['question']); - $poll_obj->setVar('description', @$_POST['description']); - $end_time = XoopsRequest::getString('end_time', '', 'POST'); - if (!empty($end_time)) { - $timezone = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; - // $poll_obj->setVar("end_time", userTimeToServerTime(strtotime($end_time), $timezone)); - //Hack by Irmtfan - $poll_obj->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); - } - $poll_obj->setVar('display', 0); - $poll_obj->setVar('weight', (int)(@$_POST['weight'])); - $poll_obj->setVar('multiple', (int)(@$_POST['multiple'])); - if (!empty($_POST['notify']) && $end_time > time()) { - // if notify, set mail status to 'not mailed' - $poll_obj->setVar('mail_status', POLL_NOTMAILED); - } else { - // if not notify, set mail status to already "mailed" - $poll_obj->setVar('mail_status', POLL_MAILED); - } - - if (!$poll_obj->store()) { - xoops_error($poll_obj->getHtmlErrors); - break; - } - $i = 0; - $option_id = empty($_POST['option_id']) ? null : $_POST['option_id']; - $option_color = empty($_POST['option_color']) ? null : $_POST['option_color']; - foreach ($option_id as $opid) { - $option_obj = new \UmfrageOption($opid); - $option_text[$i] = trim($option_text[$i]); - if ('' !== $option_text[$i]) { - $option_obj->setVar('option_text', $option_text[$i]); - $option_obj->setVar('option_color', $option_color[$i]); - $option_obj->store(); - } else { - if (false !== $option_obj->delete()) { - \UmfrageLog::deleteByOptionId($option->getVar('option_id')); - } - } - ++$i; - } - $poll_obj->updateCount(); - // include_once $GLOBALS['xoops']->path("class" . "/template.php"); - // xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); - // redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_DBUPDATED); - } - - // clear the template cache so changes take effect immediately - include_once $GLOBALS['xoops']->path('class/template.php'); - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - - // update topic to indicate it has a poll - $topic_obj->setVar('topic_haspoll', 1); - $topic_obj->setVar('poll_id', $poll_obj->getVar('poll_id')); - $success = $topicHandler->insert($topic_obj); - if (!$success) { - xoops_error($topicHandler->getHtmlErrors()); - } else { - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_POLL_DBUPDATED); - } - break; - - case 'addmore': - if ('xoopspoll' === $pollmodules) { - $poll_obj = $xpPollHandler->get($poll_id); - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - } else { // Umfrage - $poll_obj = new \Umfrage($poll_id); - } - $question = $poll_obj->getVar('question'); - unset($poll_obj); - $poll_form = new XoopsThemeForm(_MD_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); - $poll_form->addElement(new XoopsFormLabel(_MD_POLL_POLLQUESTION, $question)); - if ('xoopspoll' === $pollmodules) { - $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); - } else { - $option_tray = new XoopsFormElementTray(_MD_POLL_POLLOPTIONS, ''); - $barcolor_array = XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$pollmodules}/assets/images/colorbars/")); - for ($i = 0; $i < 10; ++$i) { - $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); - $option_text = new XoopsFormText('', 'option_text[]', 50, 255); - $option_tray->addElement($option_text); - $color_select = new XoopsFormSelect('', "option_color[{$i}]", $current_bar); - $color_select->addOptionArray($barcolor_array); - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$pollmodules}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); - $color_label = new XoopsFormLabel('', "url("modules/{$pollmodules}/assets/images/colorbars/{$current_bar}") - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' />
    "); - $option_tray->addElement($color_select); - $option_tray->addElement($color_label); - unset($color_select, $color_label, $option_text); - if (!next($barcolor_array)) { - reset($barcolor_array); - } - } - } - $poll_form->addElement($option_tray); - $poll_form->addElement(new XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); - // $poll_form->addElement(new XoopsFormButton('', 'poll_submit', _SUBMIT, 'submit')); - $poll_form->addElement(new XoopsFormHidden('op', 'savemore')); - $poll_form->addElement(new XoopsFormHidden('topic_id', $topic_id)); - $poll_form->addElement(new XoopsFormHidden('poll_id', $poll_id)); - - echo '

    ' . _MD_POLL_POLLCONF . "

    \n"; - $poll_form->display(); - break; - - case 'savemore': - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - - $option_text = $_POST['option_text'] ?? ''; - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; - $option_string = trim($option_string); - if (empty($option_string)) { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLOPTIONS . ' !'); - } - - if ('xoopspoll' === $pollmodules) { - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - } - $i = 0; - $option_color = empty($_POST['option_color']) ? null : $_POST['option_color']; - foreach ($option_text as $optxt) { - $optxt = trim($optxt); - if ('' !== $optxt) { - if ('xoopspoll' === $pollmodules) { - $option_obj = $xpOptHandler->create(); - $option_obj->setVar('option_text', $optxt); - $option_obj->setVar('poll_id', $poll_id); - $option_obj->setVar('option_color', $option_color[$i]); - $xpOptHandler->insert($option_obj); - } else { // Umfrage - $option_obj = new \UmfrageOption(); - $option_obj->setVar('option_text', $optxt); - $option_obj->setVar('poll_id', $poll_id); - $option_obj->setVar('option_color', $option_color[$i]); - $option_obj->store(); - } - unset($option_obj); - } - ++$i; - } - include_once $GLOBALS['xoops']->path('class/template.php'); - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - redirect_header("polls.php?op=edit&poll_id={$poll_id}&topic_id={$topic_id}", 2, _MD_POLL_DBUPDATED); - break; - - case 'delete': - echo '

    ' . _MD_POLL_POLLCONF . "

    \n"; - if ('xoopspoll' === $pollmodules) { - $poll_obj = $xpPollHandler->get($poll_id); - } else { - $poll_obj = new \Umfrage($poll_id); - } - xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_POLL_RUSUREDEL, $poll_obj->getVar('question'))); - break; - - case 'delete_ok': - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - //try and delete the poll - if ('xoopspoll' === $pollmodules) { - $poll_obj = $xpPollHandler->get($poll_id); - $status = $xpPollHandler->delete($poll_obj); - if (false !== $status) { - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - $xpOptHandler->deleteByPollId($poll_id); - $xpLogHandler->deleteByPollId($poll_id); - } else { - $msg = $xpPollHandler->getHtmlErrors(); - } - } else { - $poll_obj = new \Umfrage($poll_id); - $status = $poll_obj->delete(); - if (false !== $status) { - \UmfrageOption::deleteByPollId($poll_id); - \UmfrageLog::deleteByPollId($poll_id); - } else { - $msg = $poll_obj->getHtmlErrors(); - } - } - if (false !== $status) { - include_once $GLOBALS['xoops']->path('class/template.php'); - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - // delete comments for this poll - xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); - - $topic_obj->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone - $topic_obj->setVar('topic_haspoll', 0); - $topic_obj->setVar('poll_id', 0); - $success = $topicHandler->insert($topic_obj); - if (!$success) { - xoops_error($topicHandler->getHtmlErrors()); - break; - } - /* - $sql = "UPDATE " . $xoopsDB->prefix("bb_topics") . " SET votes = 0, topic_haspoll = 0, poll_id = 0 WHERE topic_id = {$topic_id}"; - if ( !$result = $xoopsDB->query($sql) ) { - //xoops_error($xoopsDB->error()); - } - */ - } else { - xoops_error($msg); - break; - } - redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_DBUPDATED); - break; - - case 'restart': - if ('xoopspoll' === $pollmodules) { - $default_poll_duration = XoopspollConstants::DEFAULT_POLL_DURATION; - } else { // Umfrage - $default_poll_duration = (86400 * 10); - } - $poll_form = new XoopsThemeForm(_MD_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); - // $expire_text = new XoopsFormText(_MD_POLL_EXPIRATION . "
    " . _MD_POLL_FORMAT . "
    " . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), "Y-m-d H:i:s")) . "
    ", "end_time", 20, 19, formatTimestamp(time() + 604800, "Y-m-d H:i:s")); - $expire_text = new XoopsFormText(_MD_POLL_EXPIRATION . '
    ' . _MD_POLL_FORMAT . '
    ' . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), _DATESTRING)) . '
    ', 'end_time', 20, 19, - formatTimestamp(time() + $default_poll_duration, _DATESTRING)); - $poll_form->addElement($expire_text); - $poll_form->addElement(new XoopsFormRadioYN(_MD_POLL_NOTIFY, 'notify', 1)); - $poll_form->addElement(new XoopsFormRadioYN(_MD_POLL_RESET, 'reset', 0)); - $poll_form->addElement(new XoopsFormHidden('op', 'restart_ok')); - $poll_form->addElement(new XoopsFormHidden('topic_id', $topic_id)); - $poll_form->addElement(new XoopsFormHidden('poll_id', $poll_id)); - $poll_form->addElement(new XoopsFormButton('', 'poll_submit', _MD_POLL_RESTART, 'submit')); - - echo '

    ' . _MD_POLL_POLLCONF . "

    \n"; - $poll_form->display(); - - break; - - case 'restart_ok': - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - - if ('xoopspoll' === $pollmodules) { - $poll_obj = $xpPollHandler->get($poll_id); - $default_poll_duration = XoopspollConstants::DEFAULT_POLL_DURATION; - $poll_mailed = XoopspollConstants::POLL_MAILED; - $poll_not_mailed = XoopspollConstants::POLL_NOT_MAILED; - } else { // Umfrage - $poll_obj = new Umfrage($poll_id); - $default_poll_duration = (86400 * 10); - $poll_not_mailed = POLL_NOTMAILED; - $poll_mailed = POLL_MAILED; - } - - $end_time = empty($_POST['end_time']) ? 0 : (int)$_POST['end_time']; - if (!empty($end_time)) { - $timezone = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; - // $poll_obj->setVar("end_time", userTimeToServerTime(strtotime($end_time), $timezone)); - //Hack by irmtfan - $poll_obj->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); - } else { - $poll_obj->setVar('end_time', time() + $default_poll_duration); - } - if (!empty($_POST['notify']) && ($end_time > time())) { - // if notify, set mail status to "not mailed" - $poll_obj->setVar('mail_status', $poll_not_mailed); - } else { - // if not notify, set mail status to already "mailed" - $poll_obj->setVar('mail_status', $poll_mailed); - } - - if ('xoopspoll' === $pollmodules) { - if (!$xpPollHandler->insert($poll_obj)) { // update the poll - xoops_error($poll_obj->getHtmlErrors()); - exit(); - } - if (!empty($_POST['reset'])) { // reset all vote/voter counters - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - $xpLogHandler->deleteByPollId($poll_id); - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $xpOptHandler->resetCountByPollId($poll_id); - $xpPollHandler->updateCount($poll_obj); - } - } else { - if (!$poll_obj->store()) { // update the poll - xoops_error($poll_obj->getHtmlErrors()); - exit(); - } - if (!empty($_POST['reset'])) { // reset all logs - UmfrageLog::deleteByPollId($poll_id); - UmfrageOption::resetCountByPollId($poll_id); - $poll_obj->updateCount(); - } - } - - // clear the topic votes - /* - $topic_obj->setVar('votes', 0); - $success = $topicHandler->insert($topic_obj); - if (!$success) { - xoops_error($topicHandler->getHtmlErrors()); - break; - } - */ - include_once $GLOBALS['xoops']->path('class/template.php'); - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_DBUPDATED); - break; - - case 'log': - if ('xoopspoll' === $pollmodules) { - redirect_header($GLOBALS['xoops']->url("modules/xoopspoll/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_LOG_XOOPSPOLL_ADMIN_REDIRECT); - } else { - echo '

    ' . _MD_POLL_POLLCONF . "

    \n" . '
    ' . _MD_VIEW_LOG . "\n" . '
    ' . _MD_LOG_NOT_IMPLEMENTED . "\n"; - } - break; -} - -// irmtfan move to footer.php -include_once __DIR__ . '/footer.php'; -include $GLOBALS['xoops']->path('footer.php'); diff --git a/extras/newbb_4x/irmtfan/readme.txt b/extras/newbb_4x/irmtfan/readme.txt deleted file mode 100644 index 4e23682..0000000 --- a/extras/newbb_4x/irmtfan/readme.txt +++ /dev/null @@ -1,13 +0,0 @@ -SUPPORT OF CBB 4.31 (irmtfan branch): - -In the directory /extras/newbb/irmtfan are the files for CBB (NewBB) 4.3 to use -either umfrage or Xoopspoll. Simply copy the files into the newbb directory of -your installation. - -SmartClone Usage -================ -If you are going to use SmartClone you must run SmartClone on the entire -/xoopspoll directory (including the ./xoopspoll/extras directory) BEFORE you -copy the files to the newbb installation directory. - -You may not rename 'xoopspoll' to 'umfrage'. \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/templates/css/index.html b/extras/newbb_4x/irmtfan/templates/css/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/templates/css/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/templates/css/language/english/index.html b/extras/newbb_4x/irmtfan/templates/css/language/english/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/templates/css/language/english/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/templates/css/language/english/style.css b/extras/newbb_4x/irmtfan/templates/css/language/english/style.css deleted file mode 100644 index 476f432..0000000 --- a/extras/newbb_4x/irmtfan/templates/css/language/english/style.css +++ /dev/null @@ -1,425 +0,0 @@ -/* -- style.css -- */ -.forum_header { - float: center; - overflow: hidden; - border: 1px solid #aaaaaa; - width: 100%; -} - -.forum_title { - float: left; - text-align: left; - padding: 5px; - width: 100%; - -} - -.forum_title a { - font-weight: bold; -} - -.forum_stats { - float: center; - overflow: hidden; - text-align: left; - /* border:1px solid #aaaaaa; */ - padding: 5px; -} - -.forum_stats_left { - float: left; - text-align: left; - width: 45%; -} - -.forum_stats_right { - float: right; - text-align: right; - width: 45%; -} - -.forum_body { - margin-top: -10px; - padding-top: 20px; - float: center; - width: 99%; - overflow: hidden; -} - -.forum_footer { - float: center; - width: 99%; - overflow: hidden; -} - -.index_category { - border: 0; - /*margin-top: -10px; - margin-bottom: 5px;*/ -} - -.ThreadUserName a { - font-weight: bold; - margin-bottom: 2px; - /*color: #000; irmtfan */ -} - -.ThreadTitle, .ThreadTitle a { - font-weight: bold; - margin-bottom: 2px; - /*color: #fff; irmtfan */ -} - -.icon_left { - float: left; - text-align: left; -} - -.icon_right { - float: right; - text-align: right; -} - -div.karma { - background-color: transparent; - text-align: left; - border: 1px solid #DDDDFF; - border-right-color: #AAAAAA; - border-bottom-color: #AAAAAA; - padding: 10px; -} - -span.digest { -} - -span.index_title { - float: left; - border: 0; -} - -span.index_extra { - float: right; - padding: 2px; - border: 0; -} - -div.signature { - bottom: 10px; - border-top: 1px inherit; -} - -div#index_welcome { - margin: 10px; -} - -html > body div#index_welcome { - margin-bottom: 15px; -} - -#index_welcome div.title { - font-size: 18px; - font-weight: bold; - border-bottom: dashed 1px; - padding: 5px; -} - -#index_welcome div.desc { - padding: 5px; - font-size: 12px; - color: #000; -} - -#index_welcome div.visit { - padding: 10px 5px; -} - -.left { - text-align: left; -} - -.right { - text-align: right; -} - -.floatleft { - float: left; -} - -.floatright { - float: right; -} - -#index_forum a { - font-weight: bold; -} - -table.index_category { - border: 0; - margin-top: -10px; - margin-bottom: 5px; -} - -table.index_category td { - padding: 2px; -} - -table.index_category td a:first-letter { -} - -table.index_category .desc, table.index_category .desc a { - font-weight: normal !important; - padding-left: 0; - margin-top: 5px; - margin-bottom: 0; -} - -table.index_category .desc:first-letter, table.index_category .desc a:first-letter { -} - -#index_forum span.item { - padding: 0 0 0 0; - margin: 0; - border: 0; -} - -#index_forum span.extra { - float: right; - text-align: left; - margin: 0; -} - -div#forum_header { - margin: 5px; -} - -#forum_header div { - padding-top: 5px; -} - -/* -- dropdown menu -- */ - -div.dropdown { - float: left; -} - -div.dropdown .menu, div.dropdown .userbar { - font-weight: bold; - float: left; - margin: 0 1px; - border: 0 !important; - padding: 0; -} - -div.dropdown .item { - font-weight: bold; - padding: 2px 5px; - white-space: nowrap; - border: 0 !important; -} - -div.dropdown ul, div.dropdown table { - width: 135px; -} - -/* -- dropdown menu -- */ - -/* -- user level -- */ -table.userlevel { - width: 90%; - border: 0; - padding: 0; - border-collapse: collapse; - border-spacing: 0; - text-align: left; -} - -table.userlevel td { - height: 13px; - padding: 0; -} - -table.userlevel td.end { - width: 3px; -} - -table.userlevel td.end img { - width: 3px; - height: 13px; -} - -table.userlevel td.center { - width: 100%; -} - -table.userlevel td.center img { - height: 12px; -} - -/* -- user level -- */ - -span.online_admin { - color: #FFA34F; -} - -span.online_moderator { - color: #006600; -} - -/* - * From http://www.positioniseverything.net/easyclearing.html - */ -.clear:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; -} - -.clear { - display: inline-table; -} - -/* Hides from IE-mac \*/ -* html .clear { - height: 1%; -} - -.clear { - display: block; -} - -/* End hide from IE-mac */ - -/* color -- dropdown menu for Forum */ -div.dropdown a, div.dropdown .menubar a { - /* irmtfan remove hardcode color color:#FFF; */ -} - -div.dropdown .menu, div.dropdown .menubar, div.dropdown .item, div.dropdown .separator { - /* irmtfan remove hardcode color background-color: #436792;*/ - /* same color set as in your theme/style.ss .th{} is recommended */ - /* irmtfan remove hardcode color color:#FFF; */ -} - -div.dropdown .separator { - border: 1px inset #e0e0e0; -} - -div.dropdown .menu a:hover, div.dropdown .userbar a:hover { - color: #333; -} - -/* irmtfan class added for solve some hard codes */ -.post_edit { - float: right; - padding: 5px; - margin-top: 10px; - border: 1px solid #000; - font-size: small; -} - -.post_ip { - float: right; - padding: 5px; - margin-top: 10px; -} - -.pagenav { - float: right; - text-align: right; - padding: 5px; -} - -.align_left, #align_left { - margin-left: 0; - text-align: left; -} - -.align_right, #align_right { - margin-right: 0; - text-align: right; -} - -.poll { - text-align: center; - margin: 3px 3px 1.5em 3px; -} - -.pointer { - cursor: pointer; - padding: 2px; -} - -/* irmtfan source: http://jsfiddle.net/VTLmj/ -you can customize each button like this: -span.forum_icon.forum_button#p_edit -span.forum_icon.forum_button#p_edit:hover -span.forum_icon.forum_button#p_edit:active -find all image names in newbb/include/images.php -*/ -span.forum_icon.forum_button { - background: #407DC7; - background-image: -webkit-gradient(linear, left top, left bottom, from(#407DC7), to(#4279B8)); - background-image: linear-gradient(#407DC7, #4279B8); - border-width: 1px; - color: white; - padding: 4px 4px; - text-shadow: 0 1px 0 gray; - border-color: white #A1C1E6 #2B4763 #A1C1E6; - border-style: solid; - border-radius: 5px; - -webkit-box-shadow: 0 1px 7px #080808; - box-shadow: 0 1px 7px #080808; - font-weight: bold; -} - -span.forum_icon.forum_button:hover { - -webkit-box-shadow: 0 1px 5px #222; - box-shadow: 0 1px 5px #222; -} - -span.forum_icon.forum_button:active { - -webkit-box-shadow: inset 0 1px 7px #565656; - box-shadow: inset 0 1px 7px #565656; - border-color: white #a1c1e6 black #a1c1e6; - font-weight: normal; -} - -span.newbb_highlight { - background-color: #FFFF80 !important; - font-weight: bold !important; -} - -span.term0 { - background-color: #00FF00 !important; -} - -span.term1 { - background-color: #FF0000 !important; -} - -span.term2 { - background-color: #0000FF !important; -} - -.topic-read { -} - -.topic-new { - -webkit-box-shadow: inset 0 10px 10px 0 rgba(0, 0, 0, .5); - box-shadow: inset 0 10px 10px 0 rgba(0, 0, 0, .5); -} - -.forum-read { -} - -.forum-new { - -webkit-box-shadow: inset 0 10px 10px 0 rgba(0, 0, 0, .5); - box-shadow: inset 0 10px 10px 0 rgba(0, 0, 0, .5); -} - -.newbb_select_text { -} - -/* color - end */ diff --git a/extras/newbb_4x/irmtfan/templates/css/language/index.html b/extras/newbb_4x/irmtfan/templates/css/language/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/templates/css/language/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/templates/css/language/persian/index.html b/extras/newbb_4x/irmtfan/templates/css/language/persian/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/templates/css/language/persian/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/templates/css/language/persian/style.css b/extras/newbb_4x/irmtfan/templates/css/language/persian/style.css deleted file mode 100644 index af2bfd1..0000000 --- a/extras/newbb_4x/irmtfan/templates/css/language/persian/style.css +++ /dev/null @@ -1,431 +0,0 @@ -/* -- style.css -- */ -.forum_header { - float: center; - overflow: hidden; - border: 1px solid #aaaaaa; - width: 100%; -} - -.forum_title { - float: /*irmtfan left*/ right; - text-align: /*irmtfan left*/ right; - padding: 5px; - width: 100%; - -} - -.forum_title a { - font-weight: bold; -} - -.forum_stats { - float: center; - overflow: hidden; - text-align: /*irmtfan left*/ right; - /* border:1px solid #aaaaaa; */ - padding: 5px; -} - -.forum_stats_left { - float: /*irmtfan left*/ right; - text-align: /*irmtfan left*/ right; - width: 45%; -} - -.forum_stats_right { - float: /*irmtfan right*/ left; - text-align: /*irmtfan right*/ left; - width: 45%; -} - -.forum_body { - margin-top: -10px; - padding-top: 20px; - float: center; - width: 99%; - overflow: hidden; -} - -.forum_footer { - float: center; - width: 99%; - overflow: hidden; -} - -.index_category { - border: 0; - /*margin-top: -10px; - margin-bottom: 5px;*/ -} - -.ThreadUserName a { - font-weight: bold; - margin-bottom: 2px; - /*color: #000; irmtfan */ -} - -.ThreadTitle, .ThreadTitle a { - font-weight: bold; - margin-bottom: 2px; - /*color: #fff; irmtfan */ -} - -.icon_left { - float: /*irmtfan left*/ right; - text-align: /*irmtfan left*/ right; -} - -.icon_right { - float: /*irmtfan right*/ left; - text-align: /*irmtfan right*/ left; -} - -div.karma { - background-color: transparent; - text-align: left; - border: 1px solid #DDDDFF; - border-right-color: #AAAAAA; - border-bottom-color: #AAAAAA; - padding: 10px; -} - -span.digest { -} - -span.index_title { - float: /*irmtfan left*/ right; - border: 0; -} - -span.index_extra { - float: /*irmtfan right*/ left; - padding: 2px; - border: 0; -} - -div.signature { - bottom: 10px; - border-top: 1px inherit; -} - -div#index_welcome { - margin: 10px; -} - -html > body div#index_welcome { - margin-bottom: 15px; -} - -#index_welcome div.title { - font-size: 18px; - font-weight: bold; - border-bottom: dashed 1px; - padding: 5px; -} - -#index_welcome div.desc { - padding: 5px; - font-size: 12px; - color: #000; -} - -#index_welcome div.visit { - padding: 10px 5px; -} - -.left { - text-align: /*irmtfan left*/ right; -} - -.right { - text-align: /*irmtfan right*/ left; -} - -.floatleft { - float: /*irmtfan left*/ right; -} - -.floatright { - float: /*irmtfan right*/ left; -} - -#index_forum a { - font-weight: bold; -} - -table.index_category { - border: 0; - margin-top: -10px; - margin-bottom: 5px; -} - -table.index_category td { - padding: 2px; -} - -table.index_category td a:first-letter { -} - -table.index_category .desc, table.index_category .desc a { - font-weight: normal !important; - /* irmtfan padding-left: 0; */ - padding-right: 0; - margin-top: 5px; - margin-bottom: 0; -} - -table.index_category .desc:first-letter, table.index_category .desc a:first-letter { -} - -#index_forum span.item { - padding: 0 0 0 0; - margin: 0; - border: 0; -} - -#index_forum span.extra { - float: /*irmtfan right*/ left; - text-align: /*irmtfan left*/ right; - margin: 0; -} - -div#forum_header { - margin: 5px; -} - -#forum_header div { - padding-top: 5px; -} - -/* -- dropdown menu -- */ - -div.dropdown { - float: /*irmtfan left*/ right; -} - -div.dropdown .menu, div.dropdown .userbar { - font-weight: bold; - float: /*irmtfan left*/ right; - margin: 0 1px; - border: 0 !important; - padding: 0; -} - -div.dropdown .item { - font-weight: bold; - padding: 2px 5px; - white-space: nowrap; - border: 0 !important; -} - -div.dropdown ul, div.dropdown table { - width: 135px; -} - -/* -- dropdown menu -- */ - -/* -- user level -- */ -table.userlevel { - width: 90%; - border: 0; - padding: 0; - border-collapse: collapse; - border-spacing: 0; - text-align: /*irmtfan left*/ right; -} - -table.userlevel td { - height: 13px; - padding: 0; -} - -table.userlevel td.end { - width: 3px; -} - -table.userlevel td.end img { - width: 3px; - height: 13px; -} - -table.userlevel td.center { - width: 100%; -} - -table.userlevel td.center img { - height: 12px; -} - -/* -- user level -- */ - -span.online_admin { - color: #FFA34F; -} - -span.online_moderator { - color: #006600; -} - -/* - * From http://www.positioniseverything.net/easyclearing.html - */ -.clear:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; -} - -.clear { - display: inline-table; -} - -/* Hides from IE-mac \*/ -* html .clear { - height: 1%; -} - -.clear { - display: block; -} - -/* End hide from IE-mac */ - -/* color -- dropdown menu for Forum */ -div.dropdown a, div.dropdown .menubar a { - /* irmtfan remove hardcode color color:#FFF; */ -} - -div.dropdown .menu, div.dropdown .menubar, div.dropdown .item, div.dropdown .separator { - /* irmtfan remove hardcode color background-color: #436792;*/ - /* same color set as in your theme/style.ss .th{} is recommended */ - /* irmtfan remove hardcode color color:#FFF; */ -} - -div.dropdown .separator { - border: 1px inset #e0e0e0; -} - -div.dropdown .menu a:hover, div.dropdown .userbar a:hover { - color: #333; -} - -/* irmtfan class added for solve some hard codes */ -.post_edit { - float: /*irmtfan right*/ left; - padding: 5px; - margin-top: 10px; - border: 1px solid #000; - font-size: small; -} - -.post_ip { - float: /*irmtfan right*/ left; - padding: 5px; - margin-top: 10px; -} - -.pagenav { - float: /*irmtfan right*/ left; - text-align: /*irmtfan right*/ left; - padding: 5px; -} - -.align_left, #align_left { - direction: rtl; - /* irmtfan margin-left: 0; */ - margin-right: 0; - text-align: /*irmtfan left*/ right; -} - -.align_right, #align_right { - direction: rtl; - /* irmtfan margin-right: 0; */ - margin-left: 0; - text-align: /*irmtfan right*/ left; -} - -.poll { - direction: rtl; - text-align: center; - margin: 3px 3px 1.5em 3px; -} - -.pointer { - cursor: pointer; - padding: 2px; -} - -/* irmtfan source: http://jsfiddle.net/VTLmj/ -you can customize each button like this: -span.forum_icon.forum_button#p_edit -span.forum_icon.forum_button#p_edit:hover -span.forum_icon.forum_button#p_edit:active -find all image names in newbb/include/images.php -*/ -span.forum_icon.forum_button { - background: #407DC7; - background-image: -webkit-gradient(linear, left top, left bottom, from(#407DC7), to(#4279B8)); - background-image: linear-gradient(#407DC7, #4279B8); - border-width: 1px; - color: white; - padding: 4px 4px; - text-shadow: 0 1px 0 gray; - border-color: white #A1C1E6 #2B4763 #A1C1E6; - border-style: solid; - border-radius: 5px; - -webkit-box-shadow: 0 1px 7px #080808; - box-shadow: 0 1px 7px #080808; - font-weight: bold; -} - -span.forum_icon.forum_button:hover { - -webkit-box-shadow: 0 1px 5px #222; - box-shadow: 0 1px 5px #222; -} - -span.forum_icon.forum_button:active { - -webkit-box-shadow: inset 0 1px 7px #565656; - box-shadow: inset 0 1px 7px #565656; - border-color: white #a1c1e6 black #a1c1e6; - font-weight: normal; -} - -span.newbb_highlight { - background-color: #FFFF80 !important; - font-weight: bold !important; -} - -span.term0 { - background-color: #00FF00 !important; -} - -span.term1 { - background-color: #FF0000 !important; -} - -span.term2 { - background-color: #0000FF !important; -} - -.topic-read { -} - -.topic-new { - -webkit-box-shadow: inset 0 10px 10px 0 rgba(0, 0, 0, .5); - box-shadow: inset 0 10px 10px 0 rgba(0, 0, 0, .5); -} - -.forum-read { -} - -.forum-new { - -webkit-box-shadow: inset 0 10px 10px 0 rgba(0, 0, 0, .5); - box-shadow: inset 0 10px 10px 0 rgba(0, 0, 0, .5); -} - -.newbb_select_text { -} - -/* color - end */ diff --git a/extras/newbb_4x/irmtfan/templates/index.html b/extras/newbb_4x/irmtfan/templates/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/irmtfan/templates/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/irmtfan/templates/newbb_poll_results.html b/extras/newbb_4x/irmtfan/templates/newbb_poll_results.html deleted file mode 100644 index a5bbed5..0000000 --- a/extras/newbb_4x/irmtfan/templates/newbb_poll_results.html +++ /dev/null @@ -1,32 +0,0 @@ -<{*-- irmtfan hardcode removed style="text-align: center;margin: 3px;" --*}> -
    -<{if 'xoopspoll' == $pollmodules}> -
    - <{$topic_pollresult}> -
    -<{else}> - - - - - -<{*-- irmtfan hardcode removed align="right" --*}> - - -<{foreach item=option from=$poll.options}> - -<{*-- irmtfan hardcode removed align="left" --*}> - - - -<{/foreach}> - - - -
    <{$poll.question}>
    <{$poll.end_text}>
    <{$option.text}><{$option.image}> <{$option.percent}>
    - <{$poll.totalVotes}> -
    - <{$poll.totalVoters}> -
    -<{/if}> -
    diff --git a/extras/newbb_4x/irmtfan/templates/newbb_poll_results.tpl b/extras/newbb_4x/irmtfan/templates/newbb_poll_results.tpl deleted file mode 100644 index 603a77d..0000000 --- a/extras/newbb_4x/irmtfan/templates/newbb_poll_results.tpl +++ /dev/null @@ -1,32 +0,0 @@ -<{*-- irmtfan hardcode removed style="text-align: center;margin: 3px;" --*}> -
    - <{if 'xoopspoll' == $pollmodules}> -
    - <{$topic_pollresult}> -
    - <{else}> - - - - - - <{*-- irmtfan hardcode removed align="right" --*}> - - - <{foreach item=option from=$poll.options}> - - <{*-- irmtfan hardcode removed align="left" --*}> - - - - <{/foreach}> - - - -
    <{$poll.question}>
    <{$poll.end_text}>
    <{$option.text}><{$option.image}> <{$option.percent}>
    - <{$poll.totalVotes}> -
    - <{$poll.totalVoters}> -
    - <{/if}> -
    diff --git a/extras/newbb_4x/irmtfan/templates/newbb_poll_view.html b/extras/newbb_4x/irmtfan/templates/newbb_poll_view.html deleted file mode 100644 index 4c52e9d..0000000 --- a/extras/newbb_4x/irmtfan/templates/newbb_poll_view.html +++ /dev/null @@ -1,24 +0,0 @@ -<{if 'xoopspoll' == $pollmodules}> -<{$topic_pollform}> -<{else}> -
    - - - - - - -<{foreach item=option from=$poll.options}> - -<{*-- irmtfan hardcode removed align="left" --*}> - - - -<{/foreach}> - - - -
    -<{$poll.question}>
    <{$option.input}><{$option.text}>
    -
    -<{/if}> diff --git a/extras/newbb_4x/irmtfan/templates/newbb_poll_view.tpl b/extras/newbb_4x/irmtfan/templates/newbb_poll_view.tpl deleted file mode 100644 index f4afb32..0000000 --- a/extras/newbb_4x/irmtfan/templates/newbb_poll_view.tpl +++ /dev/null @@ -1,24 +0,0 @@ -<{if 'xoopspoll' == $pollmodules}> - <{$topic_pollform}> -<{else}> -
    - - - - - - - <{foreach item=option from=$poll.options}> - - <{*-- irmtfan hardcode removed align="left" --*}> - - - - <{/foreach}> - - - -
    - <{$poll.question}>
    <{$option.input}><{$option.text}>
    -
    -<{/if}> diff --git a/extras/newbb_4x/irmtfan/templates/newbb_viewtopic.html b/extras/newbb_4x/irmtfan/templates/newbb_viewtopic.html deleted file mode 100644 index 5285e84..0000000 --- a/extras/newbb_4x/irmtfan/templates/newbb_viewtopic.html +++ /dev/null @@ -1,292 +0,0 @@ -
    -
    -

    <{$lang_forum_index}>

    -<{*-- irmtfan hardcode removed align="left" --*}> -
    - <{$smarty.const._MD_FORUMHOME}> - » - <{$category.title}> - <{if $parentforum}> - <{foreach item=forum from=$parentforum}> - » - <{$forum.forum_name}> - <{/foreach}> - <{/if}> - » - <{$forum_name}> - » - <{$topic_title}> <{if $topicstatus}><{$topicstatus}><{/if}> -
    -
    -
    -
    -<{if $tagbar}> -
    - <{includeq file="db:tag_bar.tpl"}> -
    -<{/if}> - -
    - -<{if $online}> -
    - <{$smarty.const._MD_BROWSING}>  - <{foreach item=user from=$online.users}> - - <{if $user.level eq 2}> - <{$user.uname}> - <{elseif $user.level eq 1}> - <{$user.uname}> - <{else}> - <{$user.uname}> - <{/if}> -   - <{/foreach}> - <{if $online.num_anonymous}> -  <{$online.num_anonymous}> <{$smarty.const._MD_ANONYMOUS_USERS}> - <{/if}> -
    -
    -<{/if}> - -<{if $viewer_level gt 1}> - -
    - <{if $mode gt 1}> - <{*-- irmtfan mistype forum_posts_admin => form_posts_admin - action="topicmanager.php" => action="action.post.php" --*}> -
    - <{$smarty.const._ALL}>: - <{*-- irmtfan mistype mode => op --*}> - - - | - <{$smarty.const._MD_TYPE_VIEW}> - <{else}> - <{$smarty.const._MD_TYPE_ADMIN}> | - <{$smarty.const._MD_TYPE_PENDING}> | - <{$smarty.const._MD_TYPE_DELETED}> - <{/if}> -
    -
    -<{/if}> -
    -
    -<{* irmtfan add $mode to not show polls in admin mode *}> -<{if ($mode lte 1) && $topic_poll}> -<{if $topic_pollresult}> -<{includeq file="db:newbb_poll_results.html" poll=$poll}> -<{else}> -<{includeq file="db:newbb_poll_view.html" poll=$poll}> -<{/if}> -<{/if}> -
    -
    - -
    - - - - <{$down}><{$smarty.const._MD_BOTTOM}>  <{$previous}> <{$smarty.const._MD_PREVTOPIC}>  <{$next}> <{$smarty.const._MD_NEXTTOPIC}> - - - - <{$forum_reply}> <{$forum_addpoll}> <{$forum_post_or_register}> - -
    -
    -
    - -
    - -<{* -- irmtfan hardcode removed style="float: right; text-align:right;" --*}> -
    - <{$forum_page_nav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> -
    -
    -
    -
    -
    - -<{if $viewer_level gt 1 && $topic_status == 1}> -
    <{$smarty.const._MD_TOPICLOCK}>
    -
    -<{/if}> -<{*-- irmtfan remove here and move to the newbb_thread.html -<{if $post_id == 0}>
    <{/if}> ---*}> -<{foreach item=topic_post from=$topic_posts}> -<{includeq file="db:newbb_thread.html" topic_post=$topic_post mode=$mode}> -
    -
    -<{foreachelse}> -
    <{$smarty.const._MD_ERRORPOST}>
    -<{/foreach}> - -<{if $mode gt 1}> - -<{/if}> - -
    -
    -
    - <{$smarty.const._MD_FORUMHOME}> - » - <{$category.title}> -<{if $parentforum}> -<{foreach item=forum from=$parentforum}> - » - <{$forum.forum_name}> -<{/foreach}> -<{/if}> - » - <{$forum_name}> - » - <{$topic_title}> <{if $topicstatus}><{$topicstatus}><{/if}> -
    -
    -
    -
    - -
    - - -
    - <{$forum_page_nav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> <{*-- irmtfan to solve nested forms and id="xo-pagenav" issue --*}> -
    -
    -
    -
    - -
    - <{$forum_reply}> <{$forum_addpoll}> <{$forum_post_or_register}> -
    -
    -
    -
    - -<{if $quickreply.show}> - -
    - -
    -
    <{$quickreply.form}>
    -
    -
    -
    -<{/if}> - -
    -<{*-- irmtfan hardcode removed style="float: left; text-align: left;" --*}> -
    -<{foreach item=perm from=$permission_table}> -
    <{$perm}>
    -<{/foreach}> -
    -<{*-- irmtfan hardcode removed style="float: right; text-align: right;" --*}> -
    -
    - - - - - - -
    - [<{$smarty.const._MD_ADVSEARCH}>] -

    - <{$forum_jumpbox}> -
    -
    -
    -
    - -<{includeq file='db:newbb_notification_select.html'}> -<{*-- irmtfan remove - - --- end of irmtfan remove *}> - - - diff --git a/extras/newbb_4x/irmtfan/templates/newbb_viewtopic.tpl b/extras/newbb_4x/irmtfan/templates/newbb_viewtopic.tpl deleted file mode 100644 index ce14958..0000000 --- a/extras/newbb_4x/irmtfan/templates/newbb_viewtopic.tpl +++ /dev/null @@ -1,315 +0,0 @@ -
    -
    -

    <{$lang_forum_index}>

    - <{*-- irmtfan hardcode removed align="left" --*}> -
    - <{$smarty.const._MD_FORUMHOME}> - » - <{$category.title}> - <{if $parentforum}> - <{foreach item=forum from=$parentforum}> - » - <{$forum.forum_name}> - <{/foreach}> - <{/if}> - » - <{$forum_name}> - » - <{$topic_title}> <{if $topicstatus}><{$topicstatus}><{/if}> -
    -
    -
    -
    -<{if $tagbar}> -
    - <{includeq file="db:tag_bar.tpl"}> -
    -<{/if}> - -
    - -<{if $online}> -
    - <{$smarty.const._MD_BROWSING}>  - <{foreach item=user from=$online.users}> - - <{if $user.level eq 2}> - <{$user.uname}> - <{elseif $user.level eq 1}> - <{$user.uname}> - <{else}> - <{$user.uname}> - <{/if}> -   - <{/foreach}> - <{if $online.num_anonymous}> -  <{$online.num_anonymous}> <{$smarty.const._MD_ANONYMOUS_USERS}> - <{/if}> -
    -
    -<{/if}> - -<{if $viewer_level gt 1}> - -
    - <{if $mode gt 1}> - <{*-- irmtfan mistype forum_posts_admin => form_posts_admin - action="topicmanager.php" => action="action.post.php" --*}> -
    - <{$smarty.const._ALL}>: - <{*-- irmtfan mistype mode => op --*}> - - - | - <{$smarty.const._MD_TYPE_VIEW}> - <{else}> - <{$smarty.const._MD_TYPE_ADMIN}> | - <{$smarty.const._MD_TYPE_PENDING}> | - <{$smarty.const._MD_TYPE_DELETED}> - <{/if}> -
    -
    -<{/if}> -
    -
    -<{* irmtfan add $mode to not show polls in admin mode *}> -<{if ($mode lte 1) && $topic_poll}> - <{if $topic_pollresult}> - <{includeq file="db:newbb_poll_results.tpl" poll=$poll}> - <{else}> - <{includeq file="db:newbb_poll_view.tpl" poll=$poll}> - <{/if}> -<{/if}> -
    -
    - -
    - - - - <{$down}><{$smarty.const._MD_BOTTOM}>  <{$previous}> -  <{$smarty.const._MD_PREVTOPIC}>  <{$next}> -  <{$smarty.const._MD_NEXTTOPIC}> - - - - <{$forum_reply}> <{$forum_addpoll}> <{$forum_post_or_register}> - -
    -
    -
    - -
    - - <{* -- irmtfan hardcode removed style="float: right; text-align:right;" --*}> -
    - <{$forum_page_nav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> - -
    -
    -
    -
    -
    - -<{if $viewer_level gt 1 && $topic_status == 1}> -
    <{$smarty.const._MD_TOPICLOCK}>
    -
    -<{/if}> -<{*-- irmtfan remove here and move to the newbb_thread.html -<{if $post_id == 0}>
    <{/if}> ---*}> -<{foreach item=topic_post from=$topic_posts}> -<{includeq file="db:newbb_thread.tpl" topic_post=$topic_post mode=$mode}> -
    -
    -<{foreachelse}> -
    <{$smarty.const._MD_ERRORPOST}>
    -<{/foreach}> - -<{if $mode gt 1}> - -<{/if}> - -
    -
    -
    - <{$smarty.const._MD_FORUMHOME}> - » - <{$category.title}> - <{if $parentforum}> - <{foreach item=forum from=$parentforum}> - » - <{$forum.forum_name}> - <{/foreach}> - <{/if}> - » - <{$forum_name}> - » - <{$topic_title}> <{if $topicstatus}><{$topicstatus}><{/if}> -
    -
    -
    -
    - -
    - - -
    - <{$forum_page_nav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> <{*-- irmtfan to solve nested forms and id="xo-pagenav" issue --*}> -
    -
    -
    -
    - -
    - <{$forum_reply}> <{$forum_addpoll}> <{$forum_post_or_register}> -
    -
    -
    -
    - -<{if $quickreply.show}> - -
    - -
    -
    <{$quickreply.form}>
    -
    -
    -
    -<{/if}> - -
    - <{*-- irmtfan hardcode removed style="float: left; text-align: left;" --*}> -
    - <{foreach item=perm from=$permission_table}> -
    <{$perm}>
    - <{/foreach}> -
    - <{*-- irmtfan hardcode removed style="float: right; text-align: right;" --*}> -
    -
    - - - - - - -
    - [<{$smarty.const._MD_ADVSEARCH}>] -
    -
    - <{$forum_jumpbox}> -
    -
    -
    -
    - -<{includeq file='db:newbb_notification_select.html'}> -<{*-- irmtfan remove - - --- end of irmtfan remove *}> - - - diff --git a/extras/newbb_4x/irmtfan/topicmanager.php b/extras/newbb_4x/irmtfan/topicmanager.php deleted file mode 100644 index 726c743..0000000 --- a/extras/newbb_4x/irmtfan/topicmanager.php +++ /dev/null @@ -1,338 +0,0 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: phppp (D.J., infomax@gmail.com) // -// URL: http://xoopsforge.com, http://xoops.org.cn // -// Project: Article Project // -// ------------------------------------------------------------------------ // -include_once __DIR__ . '/header.php'; - -if (isset($_POST['submit'])) { - foreach (array('forum', 'newforum', 'newtopic') as $getint) { - ${$getint} = isset($_POST[$getint]) ? (int)$_POST[$getint] : 0; - } - $topic_id = array(); - if (isset($_POST['topic_id']) && !is_array($_POST['topic_id'])) { - $topic_id = array($topic_id); - } else { - $topic_id = $_POST['topic_id']; - } - foreach ($topic_id as $getint) { - ${$getint} = (int)(@$_POST[$getint]); - } -} else { - foreach (array('forum', 'topic_id') as $getint) { - ${$getint} = (int)(@$_GET[$getint]); - } -} - -if (!$topic_id) { - $redirect = empty($forum_id) ? 'index.php' : "viewforum.php?forum={$forum}"; - $redirect = $GLOBALS['xoops']->url("modules/newbb/{$redirect}"); - redirect_header($redirect, 2, _MD_ERRORTOPIC); -} -/** @var NewbbTopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); -/** @var NewbbForumHandler $forumHandler */ -$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); - -if (!$forum) { - $topic_obj = $topicHandler->get((int)$topic_id); - if (is_object($topic_obj)) { - $forum = $topic_obj->getVar('forum_id'); - } else { - $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $topic_id; - redirect_header($redirect, 2, _MD_FORUMNOEXIST); - } - unset($topic_obj); -} - -if ($xoopsModuleConfig['wol_enabled']) { - $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); - $onlineHandler->init($forum); -} -// irmtfan add restore to viewtopic -$action_array = array( - 'merge', - 'delete', - 'restore', - 'move', - 'lock', - 'unlock', - 'sticky', - 'unsticky', - 'digest', - 'undigest' -); -foreach ($action_array as $_action) { - $action[$_action] = array( - 'name' => $_action, - 'desc' => constant(strtoupper("_MD_DESC_{$_action}")), - 'submit' => constant(strtoupper("_MD_{$_action}")), - 'sql' => "topic_{$_action}=1", - 'msg' => constant(strtoupper("_MD_TOPIC{$_action}")) - ); -} -$action['lock']['sql'] = 'topic_status = 1'; -$action['unlock']['sql'] = 'topic_status = 0'; -$action['unsticky']['sql'] = 'topic_sticky = 0'; -$action['undigest']['sql'] = 'topic_digest = 0'; -$action['digest']['sql'] = 'topic_digest = 1, digest_time = ' . time(); - -// Disable cache -$xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; -// irmtfan include header.php after defining $xoopsOption['template_main'] -include_once XOOPS_ROOT_PATH . '/header.php'; - -if (isset($_POST['submit'])) { - $mode = $_POST['mode']; - - if ('delete' === $mode) { - foreach ($topic_id as $tid) { - $topic_obj = $topicHandler->get($tid); - $topicHandler->delete($topic_obj, false); - // irmtfan - sync topic after delete - $topicHandler->synchronization($topic_obj); - $forumHandler->synchronization($forum); - // $topic_obj->loadFilters("delete"); - // sync($topic_id, "topic"); - // xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'thread', $topic_id); - } - // irmtfan full URL - echo $action[$mode]['msg'] . "

    getVar('dirname') . "/viewforum.php?forum=$forum'>" . _MD_RETURNTOTHEFORUM . "

    " . _MD_RETURNFORUMINDEX . '

    '; - } elseif ('restore' === $mode) { - // /** @var NewbbTopicHandler $topicHandler */ - $forums = array(); - $topics_obj = $topicHandler->getAll(new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); - foreach (array_keys($topics_obj) as $id) { - $topic_obj =& $topics_obj[$id]; - $topicHandler->approve($topic_obj); - $topicHandler->synchronization($topic_obj); - $forums[$topic_obj->getVar('forum_id')] = 1; - } - //irmtfan remove - no need to approve posts manually - see class/post.php approve function - $criteria_forum = new Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); - $forums_obj = $forumHandler->getAll($criteria_forum); - foreach (array_keys($forums_obj) as $id) { - $forumHandler->synchronization($forums_obj[$id]); - } - unset($topics_obj, $forums_obj); - // irmtfan add restore to viewtopic - $restoretopic_id = $topic_obj->getVar('topic_id'); - // irmtfan / missing in URL - echo $action[$mode]['msg'] . "

    getVar('dirname') . "/viewtopic.php?topic_id=$restoretopic_id'>" . _MD_VIEWTHETOPIC . '

    ' . "

    getVar('dirname') . "/viewforum.php?forum=$forum'>" . _MD_RETURNTOTHEFORUM . '

    ' . "

    " . _MD_RETURNFORUMINDEX . '

    '; - } elseif ('merge' === $mode) { - $pollmodul = null; - /** @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $pollModule = $moduleHandler->getByDirname('xoopspoll'); - if (($pollModule instanceof XoopsModule) && $pollModule->isactive()) { - $pollmodul = 'xoopspoll'; - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - } else { - //Umfrage - $pollModule = $moduleHandler->getByDirname('umfrage'); - if (($pollModule instanceof XoopsModule) && $pollModule->isactive()) { - $pollmodul = 'umfrage'; - } - } - - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); - foreach ($topic_id as $tid) { - $topic_obj = $topicHandler->get($tid); - $newtopic_obj = $topicHandler->get($newtopic); - /* return false if destination topic is newer or not existing */ - /* - if ($newtopic>$tid || !is_object($newtopic_obj)) { - redirect_header("javascript:history.go(-1)", 2, _MD_ERROR); - } - */ - $criteria_topic = new Criteria('topic_id', $tid); - $criteria = new CriteriaCompo($criteria_topic); - $criteria->add(new Criteria('pid', 0)); - $postHandler->updateAll('pid', $topicHandler->getTopPostId($newtopic), $criteria, true); - $postHandler->updateAll('topic_id', $newtopic, $criteria_topic, true); - - $topic_views = $topic_obj->getVar('topic_views') + $newtopic_obj->getVar('topic_views'); - $criteria_newtopic = new Criteria('topic_id', $newtopic); - $topicHandler->updateAll('topic_views', $topic_views, $criteria_newtopic, true); - - $topicHandler->synchronization($newtopic); - - $poll_id = $topicHandler->get($tid, 'poll_id'); - if ($poll_id > 0) { - if ('xoopspoll' === $pollmodul) { - $xpPollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); - $poll = $xpPollHandler->get($poll_id); - if (false !== $xpPollHandler->delete($poll)) { - $xpOptHandler->deleteByPollId($poll_id); - $xpLogHandler->deleteByPollId($poll_id); - xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); - } - } elseif ('umfrage' === $pollmodul) { - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrage.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrageoption.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragelog.php'); - include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragerenderer.php'); - - $poll = new Umfrage($poll_id); - if ($poll->delete() !== false) { - UmfrageOption::deleteByPollId($poll_id); - UmfrageLog::deleteByPollId($poll_id); - xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); - } - } - } - - $sql = sprintf('DELETE FROM %s WHERE topic_id = %u', $xoopsDB->prefix('bb_topics'), $tid); - $result = $xoopsDB->queryF($sql); - - $sql = sprintf('DELETE FROM %s WHERE topic_id = %u', $xoopsDB->prefix('bb_votedata'), $tid); - $result = $xoopsDB->queryF($sql); - - $sql = sprintf('UPDATE %s SET forum_topics = forum_topics-1 WHERE forum_id = %u', $xoopsDB->prefix('bb_forums'), $forum); - $result = $xoopsDB->queryF($sql); - - $topic_obj->loadFilters('delete'); - $newtopic_obj->loadFilters('update'); - } - // irmtfan full URL - echo $action[$mode]['msg'] . "

    getVar('dirname') . "/viewtopic.php?topic_id={$newtopic}'>" . _MD_VIEWTHETOPIC . '

    ' . "

    getVar('dirname') . "/viewforum.php?forum={$forum}'>" . _MD_RETURNTOTHEFORUM . '

    ' . "

    getVar('dirname') . "/index.php'>" . _MD_RETURNFORUMINDEX . '

    '; - } elseif ('move' === $mode) { - if ($newforum > 0) { - $topic_id = $topic_id[0]; - $topic_obj = $topicHandler->get($topic_id); - $topic_obj->loadFilters('update'); - $topic_obj->setVar('forum_id', $newforum, true); - $topicHandler->insert($topic_obj, true); - $topic_obj->loadFilters('update'); - - $sql = sprintf('UPDATE %s SET forum_id = %u WHERE topic_id = %u', $xoopsDB->prefix('bb_posts'), $newforum, $topic_id); - if (!$r = $xoopsDB->query($sql)) { - return false; - } - $forumHandler->synchronization($forum); - $forumHandler->synchronization($newforum); - // irmtfan full URL - echo $action[$mode]['msg'] . "

    getVar('dirname') . "/viewtopic.php?topic_id=$topic_id&forum=$newforum'>" . _MD_GOTONEWFORUM . "

    " . _MD_RETURNFORUMINDEX . '

    '; - } else { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERRORFORUM); - } - } else { - $topic_id = $topic_id[0]; - $forum = $topicHandler->get($topic_id, 'forum_id'); - $forum_new = !empty($newtopic) ? $topicHandler->get($newtopic, 'forum_id') : 0; - - if (!$forumHandler->getPermission($forum, 'moderate') - || (!empty($forum_new) - && !$forumHandler->getPermission($forum_new, 'reply')) - // The forum for the topic to be merged to - || (!empty($newforum) && !$forumHandler->getPermission($newforum, 'post')) // The forum to be moved to - ) { - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id", 2, _NOPERM); - } - - if (!empty($action[$mode]['sql'])) { - $sql = sprintf('UPDATE %s SET ' . $action[$mode]['sql'] . ' WHERE topic_id = %u', $xoopsDB->prefix('bb_topics'), $topic_id); - if (!$r = $xoopsDB->query($sql)) { - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&order=$order&viewmode=$viewmode", 2, _MD_ERROR_BACK . '
    sql:' . $sql); - } - } else { - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id", 2, _MD_ERROR_BACK); - } - if ('digest' === $mode && $xoopsDB->getAffectedRows()) { - $topic_obj = $topicHandler->get($topic_id); - $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); - $statsHandler->update($topic_obj->getVar('forum_id'), 'digest'); - $userstatsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Userstats'); - if ($user_stat = $userstatsHandler->get($topic_obj->getVar('topic_poster'))) { - $z = $user_stat->getVar('user_digests') + 1; - $user_stat->setVar('user_digests', (int)$z); - $userstatsHandler->insert($user_stat); - } - } - // irmtfan full URL - echo $action[$mode]['msg'] . "

    getVar('dirname') . "/viewtopic.php?topic_id=$topic_id&forum=$forum'>" . _MD_VIEWTHETOPIC . "

    " . _MD_RETURNFORUMINDEX . '

    '; - } -} else { // No submit - $mode = $_GET['mode']; - echo "
    "; - echo ""; - echo "
    "; - echo ""; - echo ""; - echo "'; - - if ($mode === 'move') { - echo ''; - } - if ('merge' === $mode) { - echo ''; - } - echo '
    " . $action[$mode]['desc'] . '
    ' . _MD_MOVETOPICTO . ''; - $box = '
    ' . _MD_MERGETOPICTO . ''; - echo _MD_TOPIC . "ID-$topic_id -> ID: "; - echo '
    '; - echo ""; - echo ""; - echo ""; - echo ""; - echo '
    '; -} -// irmtfan move to footer.php -include_once __DIR__ . '/footer.php'; -include $GLOBALS['xoops']->path('footer.php'); diff --git a/extras/newbb_4x/irmtfan/viewtopic.php b/extras/newbb_4x/irmtfan/viewtopic.php deleted file mode 100644 index e4e2a6a..0000000 --- a/extras/newbb_4x/irmtfan/viewtopic.php +++ /dev/null @@ -1,838 +0,0 @@ - - ------------------------------------------------------------------------ - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting - source code which is considered copyrighted (c) material of the - original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - ------------------------------------------------------------------------ - Author: phppp (D.J., infomax@gmail.com) - URL: http://xoopsforge.com, http://xoops.org.cn - Project: Article Project - ------------------------------------------------------------------------ -*/ -/** - * View Forum Topic with poll support - * - * @copyright:: {@link http://xoops.org/ XOOPS Project} - * @license :: {@link http://www.fsf.org/copyleft/gpl.html GNU public license} - * @package :: newbb - * @author :: phppp (D.J.) - */ - -// irmtfan enhance include -include_once __DIR__ . '/header.php'; -$xoopsLogger->startTime('newBB_viewtopic'); -mod_loadFunctions('read', 'newbb'); -mod_loadFunctions('render', 'newbb'); -xoops_loadLanguage('user'); // irmtfan add last_login - -/*Build the page query*/ -$query_vars = ['post_id', 'topic_id', 'status', 'order', 'start', 'move', 'mode']; -$query_array = []; -foreach ($query_vars as $var) { - if (!empty($_GET[$var])) { - $query_array[$var] = "{$var}={$_GET[$var]}"; - } -} -$page_query = htmlspecialchars(implode('&', $query_array), ENT_QUOTES | ENT_HTML5); -unset($query_array); - -$forum_id = !empty($_GET['forum']) ? (int)$_GET['forum'] : 0; -$read = (!empty($_GET['read']) && 'new' == $_GET['read']) ? $_GET['read'] : ''; -$topic_id = isset($_GET['topic_id']) ? (int)$_GET['topic_id'] : 0; -$post_id = !empty($_GET['post_id']) ? (int)$_GET['post_id'] : 0; -$move = isset($_GET['move']) ? strtolower($_GET['move']) : ''; -$start = !empty($_GET['start']) ? (int)$_GET['start'] : 0; -$status = (!empty($_GET['status']) - && in_array($_GET['status'], ['active', 'pending', 'deleted'])) ? $_GET['status'] : ''; -$mode = !empty($_GET['mode']) ? (int)$_GET['mode'] : (!empty($status) ? 2 : 0); -$order = (!empty($_GET['order']) && in_array($_GET['order'], ['ASC', 'DESC'])) ? $_GET['order'] : ''; - -if ('' === $order) { - if (($xoopsUser instanceof XoopsUser) && $xoopsUser->isActive()) { - $order = (1 === $xoopsUser->getVar('uorder')) ? 'DESC' : 'ASC'; - } else { - $order = (1 === $xoopsConfig['com_order']) ? 'DESC' : 'ASC'; - } -} - -if (!$topic_id && !$post_id) { - $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}"; - redirect_header($redirect, 2, _MD_ERRORTOPIC); -} -/** @var NewbbTopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); -if (!empty($post_id)) { - $topic_obj = $topicHandler->getByPost($post_id); - $topic_id = $topic_obj->getVar('topic_id'); -} elseif (!empty($move)) { - $topic_obj = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id); - $topic_id = $topic_obj->getVar('topic_id'); -} else { - $topic_obj = $topicHandler->get($topic_id); -} - -if ((!$topic_obj instanceof \Topic) || !$topic_id = $topic_obj->getVar('topic_id')) { - $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}"; - redirect_header($redirect, 2, _MD_ERRORTOPIC); -} -$forum_id = $topic_obj->getVar('forum_id'); -/** @var NewbbForumHandler $forumHandler */ -$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); -$forum_obj = $forumHandler->get($forum_id); - -$isadmin = newbb_isAdmin($forum_obj); - -if ((!$isadmin && $topic_obj->getVar('approved') < 0) || (!$forumHandler->getPermission($forum_obj)) - || (!$topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'view')) -) { - redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $forum_id, 2, _MD_NORIGHTTOVIEW); -} - -// START irmtfan - find if topic is read or unread - for all users (member and anon) -$topic_is_unread = true; -/* if $GLOBALS['xoopsModuleConfig']["read_mode"] == 0 || - * never read && $GLOBALS['xoopsModuleConfig']["read_mode"] == 1 || - * never read && $GLOBALS['xoopsModuleConfig']["read_mode"] == 2 || - * => $topic_last_post_time_or_id_read = NULL - * if !$xoopsUser && $GLOBALS['xoopsModuleConfig']["read_mode"] == 2 - * => $topic_last_post_time_or_id_read = false - * if !$xoopsUser && $GLOBALS['xoopsModuleConfig']["read_mode"] == 1 - * => $topic_last_post_time_or_id_read = lastview(newbb_IP{ip}LT) -*/ -$topic_last_post_time_or_id_read = newbb_getRead('topic', $topic_id); -if (!empty($topic_last_post_time_or_id_read)) { - if (1 === $GLOBALS['xoopsModuleConfig']['read_mode']) { - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); - $post_obj = $postHandler->get($topic_obj->getVar('topic_last_post_id')); - $topic_is_unread = ($topic_last_post_time_or_id_read < $post_obj->getVar('post_time')); - } - if (2 === $GLOBALS['xoopsModuleConfig']['read_mode']) { - $topic_is_unread = ($topic_last_post_time_or_id_read < $topic_obj->getVar('topic_last_post_id')); - // hack jump to last post read if post_id is empty - is there any better way? - if (empty($post_id) && !empty($GLOBALS['xoopsModuleConfig']['jump_to_topic_last_post_read_enabled']) - && $topic_is_unread - ) { - header('Location: ' . $_SERVER['REQUEST_URI'] . '&post_id=' . $topic_last_post_time_or_id_read); - } - } -} -// END irmtfan - find if topic is read or unread - for all users (member and anon) - -/* Only admin has access to admin mode */ -if (!$isadmin) { - $status = ''; - $mode = 0; -} - -if (!empty($GLOBALS['xoopsModuleConfig']['enable_karma'])) { - $karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma'); - $user_karma = $karmaHandler->getUserKarma(); -} - -//$viewmode = "flat"; - -$total_posts = $topicHandler->getPostCount($topic_obj, $status); -$postsArray = $topicHandler->getAllPosts($topic_obj, $order, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, $post_id, $status); - -//irmtfan - increment topic_views only if the topic is unread -if ($topic_is_unread) { - $topic_obj->incrementCounter(); -} -newbb_setRead('topic', $topic_id, $topic_obj->getVar('topic_last_post_id')); - -$GLOBALS['xoopsOption']['template_main'] = 'newbb_viewtopic.tpl'; -// irmtfan remove and move to footer.php -//$xoopsOption['xoops_module_header']= $xoops_module_header; -// irmtfan include header.php after defining $xoopsOption['template_main'] -include_once $GLOBALS['xoops']->path('header.php'); -//$xoopsTpl->assign('xoops_module_header', $xoops_module_header); -// irmtfan new method -if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { - $xoopsTpl->assign('xoops_module_header', ' - - ' . @$xoopsTpl->get_template_vars('xoops_module_header')); -} - -if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { - $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); - $onlineHandler->init($forum_obj, $topic_obj); - $xoopsTpl->assign('online', $onlineHandler->showOnline()); -} -$xoopsTpl->assign('parentforum', $forumHandler->getParents($forum_obj)); -// irmtfan - remove icon_path and use newbb_displayImage -$xoopsTpl->assign('anonym_avatar', newbb_displayImage('anonym')); - -// START irmtfan improve infobox -$infobox = []; -$infobox['show'] = (int)$GLOBALS['xoopsModuleConfig']['show_infobox']; //4.05 -// irmtfan removed then define after array -//$xoopsTpl->assign('infobox', $infobox); //4.05 -$iconHandler = newbb_getIconHandler(); // can be use in the follwing codes in this file - -if ($infobox['show'] > 0) { - // irmtfan - remove icon_path and use newbb_displayImage - $infobox['icon'] = [ - 'expand' => $iconHandler->getImageSource('less'), - 'collapse' => $iconHandler->getImageSource('more') - ]; - if (1 === $infobox['show']) { - $infobox['style'] = 'none'; //irmtfan move semicolon - $infobox['alt'] = _MD_NEWBB_SEEUSERDATA; - $infobox['src'] = 'more'; - } else { - $infobox['style'] = 'block'; //irmtfan move semicolon - $infobox['alt'] = _MD_NEWBB_HIDEUSERDATA; - $infobox['src'] = 'less'; - } - $infobox['displayImage'] = newbb_displayImage($infobox['src'], $infobox['alt']); -} -$xoopsTpl->assign('infobox', $infobox); -// END irmtfan improve infobox - -$categoryHandler = xoops_getModuleHandler('category'); -$category_obj = $categoryHandler->get($forum_obj->getVar('cat_id'), ['cat_title']); - -$xoopsTpl->assign( - [ - 'topic_title' => '' . $topic_obj->getFullTitle() . '', - 'forum_name' => $forum_obj->getVar('forum_name'), - 'lang_nexttopic' => _MD_NEXTTOPIC, - 'lang_prevtopic' => _MD_PREVTOPIC, - 'topic_status' => $topic_obj->getVar('topic_status'), - 'category' => [ - 'id' => $forum_obj->getVar('cat_id'), - 'title' => $category_obj->getVar('cat_title') - ], - 'post_id' => $post_id, - 'topic_id' => $topic_id, - 'forum_id' => $forum_id, - 'order_current' => ('DESC' === $order) ? 'DESC' : 'ASC' - ] -); - -$t_new = newbb_displayImage('t_new', _MD_POSTNEW); -$t_reply = newbb_displayImage('t_reply', _MD_REPLY); -// irmtfan show topic status if show reg is 0 and revise forum_post_or_register -if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'post')) { - $xoopsTpl->assign('forum_post', '' . $t_new . ''); -} else { - if ($topic_obj->getVar('topic_status')) { - $xoopsTpl->assign('topic_lock', _MD_TOPICLOCKED); - } - if (!empty($GLOBALS['xoopsModuleConfig']['show_reg']) && !is_object($xoopsUser)) { - $xoopsTpl->assign('forum_register', '' . _MD_REGTOPOST . ''); - } -} -// irmtfan for backward compatibility assign forum_post_or_register smarty again. -$xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->get_template_vars('forum_post') . @$xoopsTpl->get_template_vars('forum_register') . @$xoopsTpl->get_template_vars('topic_lock')); - -if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'reply')) { - $xoopsTpl->assign('forum_reply', '' . $t_reply . ''); -} - -$poster_array = []; -$require_reply = false; -foreach ($postsArray as $eachpost) { - if ($eachpost->getVar('uid') > 0) { - $poster_array[$eachpost->getVar('uid')] = 1; - } - if ($eachpost->getVar('require_reply') > 0) { - $require_reply = true; - } -} - -$userid_array = []; -$online = []; -if (count($poster_array) > 0) { - $memberHandler = xoops_getHandler('member'); - $userid_array = array_keys($poster_array); - $user_criteria = '(' . implode(',', $userid_array) . ')'; - $users = $memberHandler->getUsers(new Criteria('uid', $user_criteria, 'IN'), true); -} else { - $users = []; -} - -$viewtopic_users = []; -if (count($userid_array) > 0) { - require $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/user.php'); - $userHandler = new \NewbbUserHandler($GLOBALS['xoopsModuleConfig']['groupbar_enabled'], $GLOBALS['xoopsModuleConfig']['wol_enabled']); - $userHandler->users = $users; - $userHandler->online = $online; - $viewtopic_users = $userHandler->getUsers(); -} -unset($users); - -if ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $require_reply) { - if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) { - $viewtopic_posters = newbb_getsession('t' . $topic_id, true); - if (!is_array($viewtopic_posters) || 0 === count($viewtopic_posters)) { - $viewtopic_posters = $topicHandler->getAllPosters($topic_obj); - newbb_setsession('t' . $topic_id, $viewtopic_posters); - } - } else { - $viewtopic_posters = $topicHandler->getAllPosters($topic_obj); - } -} else { - $viewtopic_posters = []; -} - -if ($GLOBALS['xoopsModuleConfig']['show_advertising']) { - $post_werbung = [ - 'post_id' => 0, - 'post_parent_id' => 0, - 'post_date' => 0, - 'post_image' => '', - 'post_title' => '', - 'post_text' => '

    ' . xoops_getbanner() . '
    ', - 'post_attachment' => '', - 'post_edit' => 0, - 'post_no' => 0, - 'post_signature' => _MD_ADVERTISING_BLOCK, - 'poster_ip' => '', - 'thread_action' => '', - 'thread_buttons' => '', - 'mod_buttons' => '', - 'poster' => [ - 'uid' => -1, - 'link' => _MD_ADVERTISING_USER, - 'avatar' => 'avatars/blank.gif', - 'regdate' => 0, - 'last_login' => 0, - 'rank' => ['title' => ''] - ], - // irmtfan add last_login - 'post_permalink' => '' - ]; -} - -$i = 0; -foreach ($postsArray as $eachpost) { - if ($GLOBALS['xoopsModuleConfig']['show_advertising']) { - if (2 === $i) { - $xoopsTpl->append('topic_posts', $post_werbung); - } - ++$i; - } - $xoopsTpl->append('topic_posts', $eachpost->showPost($isadmin)); -} - -if ($total_posts > $GLOBALS['xoopsModuleConfig']['posts_per_page']) { - include $GLOBALS['xoops']->path('class/pagenav.php'); - $nav = new XoopsPageNav($total_posts, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, 'start', 'topic_id=' . $topic_id . '&order=' . $order . '&status=' . $status . '&mode=' . $mode); - // if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite']) && $GLOBALS['xoopsModuleConfig']['do_rewrite'] == 1) $nav->url = XOOPS_URL . $nav->url; - if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { - $navi = $nav->renderSelect(); - } elseif ('bild' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { - $navi = $nav->renderImageNav(4); - } else { - $navi = $nav->renderNav(4); - } - $xoopsTpl->assign('forum_page_nav', $navi); -} else { - $xoopsTpl->assign('forum_page_nav', ''); -} - -if (empty($post_id)) { - $first = array_keys($postsArray); - $post_id = (!empty($first[0])) ? $first[0] : 0; -} -if (!empty($postsArray[$post_id])) { - $xoops_pagetitle = $postsArray[$post_id]->getVar('subject') . ' [' . $forum_obj->getVar('forum_name') . ']'; - $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle); - $xoopsOption['xoops_pagetitle'] = $xoops_pagetitle; - $kw = array_unique(explode(' ', strip_tags($postsArray[$post_id]->getVar('post_text')), 150)); - asort($kw); - $kwort = ''; - $z = 0; - foreach ($kw as $k) { - if (strlen(trim($k)) > 5 && $z < 30) { - $kwort .= trim($k) . ' '; - ++$z; - } - } - $xoTheme->addMeta('meta', 'keywords', $kwort); - $xoTheme->addMeta('meta', 'description', substr(strip_tags($postsArray[$post_id]->getVar('post_text')), 0, 120)); -} -unset($postsArray); - -$xoopsTpl->assign('topic_print_link', "print.php?form=1&{$page_query}"); - -$admin_actions = []; -$ad_merge = ''; -$ad_move = ''; -$ad_delete = ''; -// irmtfan add restore to viewtopic -$ad_restore = ''; -$ad_lock = ''; -$ad_unlock = ''; -$ad_sticky = ''; -$ad_unsticky = ''; -$ad_digest = ''; -$ad_undigest = ''; - -// START irmtfan add restore to viewtopic -if ($topic_obj->getVar('approved') > 0) { // if the topic is active - $admin_actions['merge'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=merge&topic_id=' . $topic_id, - 'name' => _MD_MERGETOPIC, - 'image' => $ad_merge - ]; - $admin_actions['move'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=move&topic_id=' . $topic_id, - 'name' => _MD_MOVETOPIC, - 'image' => $ad_move - ]; - $admin_actions['delete'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=delete&topic_id=' . $topic_id, - 'name' => _MD_DELETETOPIC, - 'image' => $ad_delete - ]; - if (!$topic_obj->getVar('topic_status')) { - $admin_actions['lock'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=lock&topic_id=' . $topic_id, - 'image' => $ad_lock, - 'name' => _MD_LOCKTOPIC - ]; - } else { - $admin_actions['unlock'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unlock&topic_id=' . $topic_id, - 'image' => $ad_unlock, - 'name' => _MD_UNLOCKTOPIC - ]; - } - if (!$topic_obj->getVar('topic_sticky')) { - $admin_actions['sticky'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=sticky&topic_id=' . $topic_id, - 'image' => $ad_sticky, - 'name' => _MD_STICKYTOPIC - ]; - } else { - $admin_actions['unsticky'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unsticky&topic_id=' . $topic_id, - 'image' => $ad_unsticky, - 'name' => _MD_UNSTICKYTOPIC - ]; - } - if (!$topic_obj->getVar('topic_digest')) { - $admin_actions['digest'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=digest&topic_id=' . $topic_id, - 'image' => $ad_digest, - 'name' => _MD_DIGESTTOPIC - ]; - } else { - $admin_actions['undigest'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=undigest&topic_id=' . $topic_id, - 'image' => $ad_undigest, - 'name' => _MD_UNDIGESTTOPIC - ]; - } -} else { // if the topic is pending/deleted then restore/approve - $admin_actions['restore'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=restore&topic_id=' . $topic_id, - 'name' => _MD_RESTORETOPIC, - 'image' => $ad_restore - ]; -} -// END irmtfan add restore to viewtopic - -$xoopsTpl->assign_by_ref('admin_actions', $admin_actions); -$xoopsTpl->assign('viewer_level', (int)($isadmin ? 2 : is_object($xoopsUser))); - -if ($GLOBALS['xoopsModuleConfig']['show_permissiontable']) { - $permissionHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); - $permission_table = $permissionHandler->getPermissionTable($forum_obj, $topic_obj->getVar('topic_status'), $isadmin); - $xoopsTpl->assign_by_ref('permission_table', $permission_table); -} - -// Show poll -if ($pollmodules) { - /** {@internal pollmodules set in header.php} */ - if (($topic_obj->getVar('topic_haspoll') - && $topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'vote')) - || $topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'addpoll') - ) { - if ('xoopspoll' === $pollmodules) { - xoops_load('renderer', 'xoopspoll'); - xoops_loadLanguage('main', 'xoopspoll'); - } else { - @include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrage.php'); - @include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrageoption.php'); - @include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragelog.php'); - @include_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragerenderer.php'); - } - } - - if ($topic_obj->getVar('topic_haspoll') && (0 !== $topic_obj->getVar('poll_id')) - // double check to make sure it's a non-zero poll - && $topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'vote') - ) { - $GLOBALS['xoopsTpl']->assign('topic_poll', 1); - $GLOBALS['xoopsTpl']->assign('pollmodules', $pollmodules); - $uid = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; - if ('xoopspoll' === $pollmodules) { - $xpollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); - $poll_obj = $xpollHandler->get($topic_obj->getVar('poll_id')); - if (!empty($poll_obj) && $poll_obj instanceof \XoopspollPoll) { - - /* check to see if user has rights to view the results */ - $vis_return = $poll_obj->isResultVisible(); - $isVisible = (true === $vis_return) ? true : false; - $visibleMsg = $isVisible ? '' : $vis_return; - - /* setup the module config handler */ - $configHandler = xoops_getHandler('config'); - $xp_config = $configHandler->getConfigsByCat(0, $xoopspoll->getVar('mid')); - - $GLOBALS['xoopsTpl']->assign( - [ - 'is_visible' => $isVisible, - 'visible_message' => $visibleMsg, - 'disp_votes' => $xp_config['disp_vote_nums'], - 'lang_vote' => _MD_XOOPSPOLL_VOTE, - 'lang_results' => _MD_XOOPSPOLL_RESULTS, - 'back_link' => '' - ] - ); - $renderer = new \XoopspollRenderer($poll_obj); - // $renderer->assignResults($GLOBALS['xoopsTpl']); - // check to see if user has voted, show form if not, otherwise get results for form - - $logHandler = xoops_getModuleHandler('log', 'xoopspoll'); - if ($poll_obj->isAllowedToVote() - && (!$logHandler->hasVoted($poll_obj->getVar('poll_id'), xoops_getenv('REMOTE_ADDR'), $uid)) - ) { - /* - $renderer->assignForm($GLOBALS['xoopsTpl']); - $GLOBALS['xoopsTpl']->assign('topic_pollresult', null); - */ - // $GLOBALS['xoopsTpl']->assign('can_vote', true); - // $GLOBALS['xoopsTpl']->assign('topic_pollform', $renderer->renderForm()); - $myTpl = new XoopsTpl(); - $renderer->assignForm($myTpl); - $myTpl->assign('action', $GLOBALS['xoops']->url("modules/newbb/votepolls.php?topic_id={$topic_id}&poll_id={$poll_id}")); - $topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/xoopspoll/templates/xoopspoll_view.tpl')); - $GLOBALS['xoopsTpl']->assign('topic_pollform', $topic_pollform); - } else { - // $renderer->assignResults($GLOBALS['xoopsTpl']); - $GLOBALS['xoopsTpl']->assign('can_vote', false); - $GLOBALS['xoopsTpl']->assign('topic_pollresult', $renderer->renderResults()); - } - } - } else { //Umfrage - $poll_obj = new \Umfrage($topic_obj->getVar('poll_id')); - $hasEnded = $poll_obj->getVar('end_time') < time() ? true : false; - $renderer = new \UmfrageRenderer($poll); - $xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2); - $xoopsTpl->assign('has_ended', $hasEnded); - $xoopsTpl->assign('polltype', $poll_obj->getVar('polltype')); - switch ($poll_obj->getVar('polltype')) { - case 1: //always visible - $visibleMsg = ''; - $isVisible = true; - break; - case 2: //not visible - $visibleMsg = _PL_FULLBLIND; - $isVisible = false; - break; - case 3: //visible after end of poll - $visibleMsg = _PL_HALFBLIND; - $isVisible = $hasEnded; - break; - } - - $hasvoted = 0; - if ($uid > 0) { - if (\UmfrageLog::hasVoted($topic_obj->getVar('poll_id'), xoops_getenv('REMOTE_ADDR'), $uid)) { - $hasvoted = 1; - } - } else { - $hasvoted = 1; //does not allow anon voting - } - - $xoopsTpl->assign( - [ - 'is_visible' => $isVisible, - 'visible_message' => $visibleMsg, - 'hasVoted' => $hasvoted, - 'lang_vote' => _PL_VOTE, - 'lang_results' => ($poll_obj->getVar('end_time') < time()) ? _PL_RESULTS : _PL_STANDINGS - ] - ); - - if (\UmfrageLog::hasVoted($topic_obj->getVar('poll_id'), $_SERVER['REMOTE_ADDR'], $uid) - || $poll_obj->getVar('end_time') < time() - ) { - $renderer->assignResults($xoopsTpl); - //pollresults($forumtopic->getVar('poll_id')); - $xoopsTpl->assign('topic_pollresult', 1); - setcookie('bb_polls[' . $topic_obj->getVar('poll_id') . ']', 1); - } else { - $renderer->assignForm($xoopsTpl); - //pollview($forumtopic->getVar('poll_id')); - setcookie('bb_polls[' . $topic_obj->getVar('poll_id') . ']', 1); - } - } - } - - if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'addpoll')) { - if (!$topic_obj->getVar('topic_haspoll')) { - if (($xoopsUser instanceof XoopsUser) && $xoopsUser->getVar('uid') === $topic_obj->getVar('topic_poster')) { - $t_poll = newbb_displayImage('t_poll', _MD_ADDPOLL); - $xoopsTpl->assign('forum_addpoll', '{$t_poll}"); - } - } elseif ($isadmin - || (is_object($poll) && ($xoopsUser instanceof XoopsUser) - && $xoopsUser->getVar('uid') === $poll_obj->getVar('user_id')) - ) { - $poll_edit = ''; - $poll_delete = ''; - $poll_restart = ''; - - $adminpoll_actions = []; - $adminpoll_actions['editpoll'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=edit&poll_id=' . $topic_obj->getVar('poll_id') . '&topic_id=' . $topic_id, - 'image' => $poll_edit, - 'name' => _MD_EDITPOLL - ]; - $adminpoll_actions['deletepoll'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=delete&poll_id=' . $topic_obj->getVar('poll_id') . '&topic_id=' . $topic_id, - 'image' => $poll_delete, - 'name' => _MD_DELETEPOLL - ]; - $adminpoll_actions['restartpoll'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=restart&poll_id=' . $topic_obj->getVar('poll_id') . '&topic_id=' . $topic_id . '&forum=' . $forum_id, - 'image' => $poll_restart, - 'name' => _MD_RESTARTPOLL - ]; - - $xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions); - } - } - if (isset($poll_obj)) { - unset($poll_obj); - } -} -$xoopsTpl->assign( - [ - 'p_up' => newbb_displayImage('up', _MD_TOP), - 'rating_enable' => $GLOBALS['xoopsModuleConfig']['rating_enabled'], - 'groupbar_enable' => $GLOBALS['xoopsModuleConfig']['groupbar_enabled'], - 'anonymous_prefix' => $GLOBALS['xoopsModuleConfig']['anonymous_prefix'], - // irmtfan add alt for prev next and down icons. - 'previous' => newbb_displayImage('previous', _MD_PREVTOPIC), - 'next' => newbb_displayImage('next', _MD_NEXTTOPIC), - 'down' => newbb_displayImage('down', _MD_BOTTOM), - 'post_content' => newbb_displayImage('post') - ] -); - -if (!empty($GLOBALS['xoopsModuleConfig']['rating_enabled'])) { - $xoopsTpl->assign('votes', $topic_obj->getVar('votes')); - $rating = number_format($topic_obj->getVar('rating') / 2, 0); - if ($rating < 1) { - $rating_img = newbb_displayImage('blank'); - } else { - // irmtfan - add alt key for rating - $rating_img = newbb_displayImage('rate' . $rating, constant('_MD_RATE' . $rating)); - } - $xoopsTpl->assign( - [ - 'rating_img' => $rating_img, - 'rate1' => newbb_displayImage('rate1', _MD_RATE1), - 'rate2' => newbb_displayImage('rate2', _MD_RATE2), - 'rate3' => newbb_displayImage('rate3', _MD_RATE3), - 'rate4' => newbb_displayImage('rate4', _MD_RATE4), - 'rate5' => newbb_displayImage('rate5', _MD_RATE5) - ] - ); -} - -// create jump box -if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) { - mod_loadFunctions('forum', 'newbb'); - $xoopsTpl->assign('forum_jumpbox', newbb_make_jumpbox($forum_id)); -} - -$xoopsTpl->assign( - [ - 'lang_forum_index' => sprintf(_MD_FORUMINDEX, htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)), - 'lang_from' => _MD_FROM, - 'lang_joined' => _MD_JOINED, - 'lang_posts' => _MD_POSTS, - 'lang_poster' => _MD_POSTER, - 'lang_thread' => _MD_THREAD, - 'lang_edit' => _EDIT, - 'lang_delete' => _DELETE, - 'lang_reply' => _REPLY, - 'lang_postedon' => _MD_POSTEDON, - 'lang_groups' => _MD_GROUPS - ] -); - -$viewmode_options = []; -if ('DESC' === $order) { - $viewmode_options[] = [ - 'link' => $GLOBALS['xoops']->url('modules/' . $xoopsModule->getVar('dirname', 'n') . "/viewtopic.php?order=ASC&status={$status}&topic_id={$topic_id}"), - 'title' => _OLDESTFIRST - ]; -} else { - $viewmode_options[] = [ - 'link' => $GLOBALS['xoops']->url('modules/' . $xoopsModule->getVar('dirname', 'n') . "/viewtopic.php?order=DESC&status=$status&topic_id={$topic_id}"), - 'title' => _NEWESTFIRST - ]; -} - -switch ($status) { - case 'active': - $current_status = '[' . _MD_TYPE_ADMIN . ']'; - break; - case 'pending': - $current_status = '[' . _MD_TYPE_PENDING . ']'; - break; - case 'deleted': - $current_status = '[' . _MD_TYPE_DELETED . ']'; - break; - default: - $current_status = ''; - break; -} -$xoopsTpl->assign( - [ - 'topicstatus' => $current_status, - 'mode' => $mode, - 'status' => $status, - 'viewmode_options' => $viewmode_options, - 'menumode' => $menumode, - 'menumode_other' => $menumode_other - ] -); -//$xoopsTpl->assign('viewmode_compact', ($viewmode=="compact")?1:0); -// changed to assign, assign_by_ref not supported under PHP 5.x -//$xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options); -//unset($viewmode_options); - -// START irmtfan add verifyUser to quick reply -//check banning -$moderateHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate'); -if (!empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled']) - && $topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'reply') - && !$moderateHandler->verifyUser(-1, '', $forum_obj->getVar('forum_id')) -) { - // END irmtfan add verifyUser to quick reply - $forum_form = new XoopsThemeForm(_MD_POSTREPLY, 'quick_reply', $GLOBALS['xoops']->url('modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php'), 'post', true); - if (!$xoopsUser instanceof XoopsUser) { - //$configHandler = xoops_getHandler('config'); - $user_tray = new XoopsFormElementTray(_MD_ACCOUNT); - $user_tray->addElement(new XoopsFormText(_MD_NAME, 'uname', 26, 255)); - $user_tray->addElement(new XoopsFormPassword(_MD_PASSWORD, 'pass', 10, 32)); - $login_checkbox = new XoopsFormCheckBox('', 'login', 1); - $login_checkbox->addOption(1, _MD_LOGIN); - $user_tray->addElement($login_checkbox); - $forum_form->addElement($user_tray); - $captcha = new XoopsFormCaptcha('', "topic_{$topic_id}_{$start}"); - $captcha->setConfig('mode', 'text'); - $forum_form->addElement($captcha); - } - - // $quickform = ( !empty($GLOBALS['xoopsModuleConfig']["editor_default"]) ) ? $GLOBALS['xoopsModuleConfig']["editor_default"] : "textarea"; - $quickform = (!empty($GLOBALS['xoopsModuleConfig']['editor_quick_default'])) ? $GLOBALS['xoopsModuleConfig']['editor_quick_default'] : 'textarea'; - $editor_configs = []; - // $editor_configs ["value"] = $message; - $editor_configs ['name'] = 'message'; - $editor_configs ['rows'] = empty($GLOBALS['xoopsModuleConfig']['editor_rows']) ? 10 : $GLOBALS['xoopsModuleConfig']['editor_rows']; - $editor_configs ['cols'] = empty($GLOBALS['xoopsModuleConfig']['editor_cols']) ? 30 : $GLOBALS['xoopsModuleConfig']['editor_cols']; - $editor_configs ['width'] = empty($GLOBALS['xoopsModuleConfig']['editor_width']) ? '100%' : $GLOBALS['xoopsModuleConfig']['editor_width']; - $editor_configs ['height'] = empty($GLOBALS['xoopsModuleConfig']['editor_height']) ? '400px' : $GLOBALS['xoopsModuleConfig']['editor_height']; - $_editor = new XoopsFormEditor(_MD_MESSAGEC, $quickform, $editor_configs, true); - $forum_form->addElement($_editor, true); - - $forum_form->addElement(new XoopsFormHidden('dohtml', 0)); - $forum_form->addElement(new XoopsFormHidden('dosmiley', 1)); - $forum_form->addElement(new XoopsFormHidden('doxcode', 1)); - $forum_form->addElement(new XoopsFormHidden('dobr', 1)); - $forum_form->addElement(new XoopsFormHidden('attachsig', 1)); - - $forum_form->addElement(new XoopsFormHidden('isreply', 1)); - - $forum_form->addElement(new XoopsFormHidden('subject', _MD_RE . ': ' . $topic_obj->getVar('topic_title', 'e'))); - $forum_form->addElement(new XoopsFormHidden('pid', empty($post_id) ? $topicHandler->getTopPostId($topic_id) : $post_id)); - $forum_form->addElement(new XoopsFormHidden('topic_id', $topic_id)); - $forum_form->addElement(new XoopsFormHidden('forum', $forum_id)); - // $forum_form->addElement(new XoopsFormHidden('viewmode', $viewmode)); - $forum_form->addElement(new XoopsFormHidden('order', $order)); - $forum_form->addElement(new XoopsFormHidden('start', $start)); - - $forum_form->addElement(new XoopsFormHidden('notify', -1)); - $forum_form->addElement(new XoopsFormHidden('contents_submit', 1)); - - $submit_button = new XoopsFormButton('', 'quick_submit', _SUBMIT, 'submit'); - $submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value == \'RE\' || document.forms.quick_reply.message.value == \'\') { alert(\'' . _MD_QUICKREPLY_EMPTY . '\'); return false;} else { return true;}"'); - $forum_form->addElement($submit_button); - - $toggles = newbb_getcookie('G', true); - // START irmtfan improve quickreply smarty variable - add alt key to quick reply button - change $display to $style for more comprehension - add toggle $quickreply['expand'] - $quickreply = []; - $qr_collapse = 't_qr'; - $qr_expand = 't_qr_expand'; // change this - $quickreply['icon'] = [ - 'expand' => $iconHandler->getImageSource($qr_expand), - 'collapse' => $iconHandler->getImageSource($qr_collapse) - ]; - $quickreply['show'] = 1; // = !empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled'] - $quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles) ? false : true) : true; - if ($quickreply['expand']) { - $quickreply['style'] = 'block'; //irmtfan move semicolon - $quickreply_icon_display = $qr_expand; - $quickreply_alt = _MD_NEWBB_HIDE . ' ' . _MD_QUICKREPLY; - } else { - $quickreply['style'] = 'none'; //irmtfan move semicolon - $quickreply_icon_display = $qr_collapse; - $quickreply_alt = _MD_NEWBB_SEE . ' ' . _MD_QUICKREPLY; - } - $quickreply['displayImage'] = newbb_displayImage($quickreply_icon_display, $quickreply_alt); - $quickreply['form'] = $forum_form->render(); - $xoopsTpl->assign('quickreply', $quickreply); - // END irmtfan improve quickreply smarty variable - unset($forum_form); -} else { - $xoopsTpl->assign('quickreply', ['show' => 0]); -} - -if ($GLOBALS['xoopsModuleConfig']['do_tag']) { - // now make sure tag module exists and is active - /** @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $tagModule = $moduleHandler->getByDirname('tag'); - if ($tagModule instanceof XoopsModule && $tagModule->isactive()) { - @include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php'); - $xoopsTpl->assign('tagbar', tagBar($topic_obj->getVar('topic_tags', 'n'))); - } else { - $xoopsTpl->assign('tagbar', ''); - } -} else { - $xoopsTpl->assign('tagbar', ''); -} -// irmtfan move to footer.php -include_once __DIR__ . '/footer.php'; -include $GLOBALS['xoops']->path('footer.php'); -$xoopsLogger->stopTime('newBB_viewtopic'); diff --git a/extras/newbb_4x/irmtfan/votepolls.php b/extras/newbb_4x/irmtfan/votepolls.php deleted file mode 100644 index 88f9dd6..0000000 --- a/extras/newbb_4x/irmtfan/votepolls.php +++ /dev/null @@ -1,158 +0,0 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // - -require_once __DIR__ . '/header.php'; -xoops_load('XoopsRequest'); - -$poll_id = isset($_GET['poll_id']) ? (int)$_GET['poll_id'] : 0; -$poll_id = isset($_POST['poll_id']) ? (int)$_POST['poll_id'] : $poll_id; -$topic_id = isset($_GET['topic_id']) ? (int)$_GET['topic_id'] : 0; -$topic_id = isset($_POST['topic_id']) ? (int)$_POST['topic_id'] : $topic_id; -$forum = isset($_GET['forum']) ? (int)$_GET['forum'] : 0; -$forum = isset($_POST['forum']) ? (int)$_POST['forum'] : $forum; - -/** @var NewbbTopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); -$topic_obj = $topicHandler->get($topic_id); -if (!$topicHandler->getPermission($topic_obj->getVar('forum_id'), $topic_obj->getVar('topic_status'), 'vote')) { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _NOPERM); -} - -if (empty($_POST['option_id'])) { - // irmtfan - add error message - simple url - redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_NOOPTION); -} - -if (($xoopspoll instanceof XoopsModule) && $xoopspoll->isactive()) { - if ('xoopspoll' === $pollmodules) { - /* xoopspoll module installed & active */ - $pollmodul = 'xoopspoll'; - xoops_load('constants', 'xoopspoll'); - xoops_loadLanguage('main', 'xoopspoll'); - $xpPollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - } else { // Umfrage - $pollmodul = 'umfrage'; - include_once XOOPS_ROOT_PATH . '/modules/umfrage/include/constants.php'; - include_once XOOPS_ROOT_PATH . '/modules/umfrage/class/umfrage.php'; - include_once XOOPS_ROOT_PATH . '/modules/umfrage/class/umfrageoption.php'; - include_once XOOPS_ROOT_PATH . '/modules/umfrage/class/umfragelog.php'; - include_once XOOPS_ROOT_PATH . '/modules/umfrage/class/umfragerenderer.php'; - } -} else { - //no active poll module found - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_POLLMODULE_ERROR); -} - -$mail_author = false; -if ('xoopspoll' === $pollmodules) { - $pollObj = $xpPollHandler->get($poll_id); - if ($pollObj instanceof \XoopspollPoll) { - if ($pollObj->getVar('multiple')) { - $optionId = XoopsRequest::getInt('option_id', 0, 'POST'); - $optionId = (array)$optionId; // type cast to make sure it's an array - $optionId = array_map('\intval', $optionId); // make sure values are integers - } else { - $optionId = $_POST['option_id']; - } - if (!$pollObj->hasExpired()) { - $msg = _MD_XOOPSPOLL_MUSTLOGIN; - //@todo:: add $url to all redirects - // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id)); - if ($pollObj->isAllowedToVote()) { - $thisVoter = (!empty($GLOBALS['xoopsUser']) - && ($GLOBALS['xoopsUser'] instanceof XoopsUser)) ? $GLOBALS['xoopsUser']->getVar('uid') : null; - $votedThisPoll = $xpLogHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $thisVoter); - if (!$votedThisPoll) { - /* user that hasn't voted before in this poll or module preferences allow it */ - $voteTime = time(); - if ($pollObj->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { - if (!$xpPollHandler->updateCount($pollObj)) { // update the count and save in db - echo $pollObj->getHtmlErrors(); - exit(); - } - $msg = _MD_XOOPSPOLL_THANKSFORVOTE; - } else { - /* there was a problem registering the vote */ - redirect_header($GLOBALS['xoops']->buildUrl('index.php', ['poll_id' => $poll_id]), XoopspollConstants::REDIRECT_DELAY_MEDIUM, _MD_XOOPSPOLL_VOTE_ERROR); - } - } else { - $msg = _MD_XOOPSPOLL_ALREADYVOTED; - } - /* set anon user vote (and the time they voted) */ - if (!$GLOBALS['xoopsUser'] instanceof XoopsUser) { - xoops_load('pollUtility', 'xoopspoll'); - \XoopspollPollUtility::setVoteCookie($poll_id, $voteTime, 0); - } - } else { - $msg = _MD_XOOPSPOLL_CANNOTVOTE; - } - } else { - /* poll has expired so just show the results */ - $msg = _MD_XOOPSPOLL_SORRYEXPIRED; - } - } else { - $msg = _MD_XOOPSPOLL_ERROR_INVALID_POLLID; - } - if (null !== $url) { - redirect_header($url, XoopspollConstants::REDIRECT_DELAY_MEDIUM, $msg); - } else { - /* - redirect_header($GLOBALS['xoops']->buildUrl("pollresults.php", array('poll_id' => $poll_id)), - XoopspollConstants::REDIRECT_DELAY_MEDIUM, - $msg); - */ - redirect_header($GLOBALS['xoops']->buildUrl('viewtopic.php', ['topic_id' => $topic_id]), XoopspollConstants::REDIRECT_DELAY_MEDIUM, $msg); - } -} else { //Umfrage - $poll = new \Umfrage($poll_id); - if (is_object($xoopsUser)) { - if (\UmfrageLog::hasVoted($poll_id, $_SERVER['REMOTE_ADDR'], $xoopsUser->getVar('uid'))) { - $msg = _PL_ALREADYVOTED; - setcookie("bb_polls[$poll_id]", 1); - } else { - // irmtfan save ip to db - $poll->vote($_POST['option_id'], $_SERVER['REMOTE_ADDR'], $xoopsUser->getVar('uid')); - $poll->updateCount(); - $msg = _PL_THANKSFORVOTE; - setcookie("bb_polls[$poll_id]", 1); - } - } else { - if (\UmfrageLog::hasVoted($poll_id, $_SERVER['REMOTE_ADDR'])) { - $msg = _PL_ALREADYVOTED; - setcookie("bb_polls[$poll_id]", 1); - } else { - $poll->vote($_POST['option_id'], $_SERVER['REMOTE_ADDR']); - $poll->updateCount(); - $msg = _PL_THANKSFORVOTE; - setcookie("bb_polls[$poll_id]", 1); - } - } -} -// irmtfan - simple url -redirect_header("viewtopic.php?topic_id={$topic_id}", 1, $msg); diff --git a/extras/newbb_4x/readme.txt b/extras/newbb_4x/readme.txt deleted file mode 100644 index db97bb5..0000000 --- a/extras/newbb_4x/readme.txt +++ /dev/null @@ -1,15 +0,0 @@ -SUPPORT OF CBB 4.0 (trunk): -=========================== -In the directory /extras/newbb_4x/trunk_4_00 are the files for the official CBB -(NewBB) 4.00 from the SVN trunk to use xoopspoll. Simply copy the files into the -newbb directory of your installation. - -SUPPORT OF CBB 4.31 (irmtfan branch): -===================================== -In the directory /extras/newbb_4x/irmtfan are the files for CBB (NewBB) 4.31 to use -either umfrage or xoopspoll. Simply copy the files into the newbb directory of -your installation. - -Note: This release does not contain the template changes required to use the - /newbb/templates_fulldiv_opacity templates. Only the default templates - from the /newbb/templates are supported in this release. \ No newline at end of file diff --git a/extras/newbb_4x/trunk_4_00/class/index.html b/extras/newbb_4x/trunk_4_00/class/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/trunk_4_00/class/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/trunk_4_00/class/post.php b/extras/newbb_4x/trunk_4_00/class/post.php deleted file mode 100644 index 8a9a0ff..0000000 --- a/extras/newbb_4x/trunk_4_00/class/post.php +++ /dev/null @@ -1,1098 +0,0 @@ - - */ -// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); - -class Post extends XoopsObject -{ - public $attachment_array = array(); - - /** - * Post constructor. - */ - public function __construct() - { - //$this->ArtObject("bb_posts"); - $this->initVar('post_id', XOBJ_DTYPE_INT); - $this->initVar('topic_id', XOBJ_DTYPE_INT, 0, true); - $this->initVar('forum_id', XOBJ_DTYPE_INT, 0, true); - $this->initVar('post_time', XOBJ_DTYPE_INT, 0, true); - $this->initVar('poster_ip', XOBJ_DTYPE_INT, 0); - $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX, ''); - $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true); - $this->initVar('pid', XOBJ_DTYPE_INT, 0); - $this->initVar('dohtml', XOBJ_DTYPE_INT, 0); - $this->initVar('dosmiley', XOBJ_DTYPE_INT, 1); - $this->initVar('doxcode', XOBJ_DTYPE_INT, 1); - $this->initVar('doimage', XOBJ_DTYPE_INT, 1); - $this->initVar('dobr', XOBJ_DTYPE_INT, 1); - $this->initVar('uid', XOBJ_DTYPE_INT, 1); - $this->initVar('icon', XOBJ_DTYPE_TXTBOX, ''); - $this->initVar('attachsig', XOBJ_DTYPE_INT, 0); - $this->initVar('approved', XOBJ_DTYPE_INT, 1); - $this->initVar('post_karma', XOBJ_DTYPE_INT, 0); - $this->initVar('require_reply', XOBJ_DTYPE_INT, 0); - $this->initVar('attachment', XOBJ_DTYPE_TXTAREA, ''); - $this->initVar('post_text', XOBJ_DTYPE_TXTAREA, ''); - $this->initVar('post_edit', XOBJ_DTYPE_TXTAREA, ''); - } - - // //////////////////////////////////////////////////////////////////////////////////// - // attachment functions TODO: there should be a file/attachment management class - /** - * @return array|mixed|null - */ - public function getAttachment() - { - if (count($this->attachment_array)) { - return $this->attachment_array; - } - $attachment = $this->getVar('attachment'); - if (empty($attachment)) { - $this->attachment_array = null; - } else { - $this->attachment_array = @unserialize(base64_decode($attachment)); - } - - return $this->attachment_array; - } - - /** - * @param $attach_key - * @return bool - */ - public function incrementDownload($attach_key) - { - if (!$attach_key) { - return false; - } - $this->attachment_array[(string)$attach_key]['num_download']++; - - return $this->attachment_array[(string)$attach_key]['num_download']; - } - - /** - * @return bool - */ - public function saveAttachment() - { - if (is_array($this->attachment_array) && count($this->attachment_array) > 0) { - $attachment_save = base64_encode(serialize($this->attachment_array)); - } else { - $attachment_save = ''; - } - $this->setVar('attachment', $attachment_save); - $sql = 'UPDATE ' - . $GLOBALS['xoopsDB']->prefix('bb_posts') - . ' SET attachment=' - . $GLOBALS['xoopsDB']->quoteString($attachment_save) - . ' WHERE post_id = ' - . $this->getVar('post_id'); - if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) { - //xoops_error($GLOBALS['xoopsDB']->error()); - return false; - } - - return true; - } - - /** - * @param null $attach_array - * @return bool - */ - public function deleteAttachment($attach_array = null) - { - global $xoopsModuleConfig; - - $attach_old = $this->getAttachment(); - if (!is_array($attach_old) || count($attach_old) < 1) { - return true; - } - $this->attachment_array = array(); - - if ($attach_array === null) { - $attach_array = array_keys($attach_old); - } // to delete all! - if (!is_array($attach_array)) { - $attach_array = array($attach_array); - } - - foreach ($attach_old as $key => $attach) { - if (in_array($key, $attach_array)) { - @unlink(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/' . $attach['name_saved']); - @unlink(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/thumbs/' . $attach['name_saved']); // delete thumbnails - continue; - } - $this->attachment_array[$key] = $attach; - } - if (is_array($this->attachment_array) && count($this->attachment_array) > 0) { - $attachment_save = base64_encode(serialize($this->attachment_array)); - } else { - $attachment_save = ''; - } - $this->setVar('attachment', $attachment_save); - - return true; - } - - /** - * @param string $name_saved - * @param string $name_display - * @param string $mimetype - * @param int $num_download - * @return bool - */ - public function setAttachment($name_saved = '', $name_display = '', $mimetype = '', $num_download = 0) - { - static $counter = 0; - $this->attachment_array = $this->getAttachment(); - if ($name_saved) { - $key = (string)(time() + $counter++); - $this->attachment_array[$key] = array( - 'name_saved' => $name_saved, - 'name_display' => isset($name_display) ? $name_display : $name_saved, - 'mimetype' => $mimetype, - 'num_download' => isset($num_download) ? (int)$num_download : 0 - ); - } - if (is_array($this->attachment_array)) { - $attachment_save = base64_encode(serialize($this->attachment_array)); - } else { - $attachment_save = null; - } - $this->setVar('attachment', $attachment_save); - - return true; - } - - /** - * TODO: refactor - * @param bool $asSource - * @return string - */ - public function displayAttachment($asSource = false) - { - global $xoopsModule, $xoopsModuleConfig; - - $post_attachment = ''; - $attachments = $this->getAttachment(); - if (is_array($attachments) && count($attachments) > 0) { - $iconHandler = newbb_getIconHandler(); - $mime_path = $iconHandler->getPath('mime'); - include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/include/functions.image.php'; - $image_extensions = array('jpg', 'jpeg', 'gif', 'png', 'bmp'); // need improve !!! - $post_attachment .= '
    ' . _MD_ATTACHMENT . ':'; - $post_attachment .= '


    '; - foreach ($attachments as $key => $att) { - $file_extension = ltrim(strrchr($att['name_saved'], '.'), '.'); - $filetype = $file_extension; - if (file_exists(XOOPS_ROOT_PATH . '/' . $mime_path . '/' . $filetype . '.gif')) { - $icon_filetype = XOOPS_URL . '/' . $mime_path . '/' . $filetype . '.gif'; - } else { - $icon_filetype = XOOPS_URL . '/' . $mime_path . '/unknown.gif'; - } - $file_size = @filesize(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/' . $att['name_saved']); - $file_size = number_format($file_size / 1024, 2) . ' KB'; - if (in_array(strtolower($file_extension), $image_extensions) && $xoopsModuleConfig['media_allowed']) { - $post_attachment .= '
    '
-                                        . $filetype
-                                        . '  ' - . $att['name_display'] - . ' (' - . $file_size - . ')'; - $post_attachment .= '
    ' . newbb_attachmentImage($att['name_saved']); - $isDisplayed = true; - } else { - $post_attachment .= ' '
-                                        . $filetype
-                                        . ' ' - . $att['name_display'] - . ' ' - . _MD_FILESIZE - . ': ' - . $file_size - . '; ' - . _MD_HITS - . ': ' - . $att['num_download']; - } - $post_attachment .= '
    '; - } - } - - return $post_attachment; - } - // attachment functions - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * @param string $poster_name - * @return bool - */ - public function setPostEdit($poster_name = '') - { - global $xoopsModuleConfig, $xoopsUser; - - if (empty($xoopsModuleConfig['recordedit_timelimit']) - || (time() - $this->getVar('post_time')) < $xoopsModuleConfig['recordedit_timelimit'] * 60 - || $this->getVar('approved') < 1 - ) { - return true; - } - if (is_object($xoopsUser) && $xoopsUser->isActive()) { - if ($xoopsModuleConfig['show_realname'] && $xoopsUser->getVar('name')) { - $edit_user = $xoopsUser->getVar('name'); - } else { - $edit_user = $xoopsUser->getVar('uname'); - } - } - $post_edit = array(); - $post_edit['edit_user'] = $edit_user; // The proper way is to store uid instead of name. However, to save queries when displaying, the current way is ok. - $post_edit['edit_time'] = time(); - - $post_edits = $this->getVar('post_edit'); - if (!empty($post_edits)) { - $post_edits = unserialize(base64_decode($post_edits)); - } - if (!is_array($post_edits)) { - $post_edits = array(); - } - $post_edits[] = $post_edit; - $post_edit = base64_encode(serialize($post_edits)); - unset($post_edits); - $this->setVar('post_edit', $post_edit); - - return true; - } - - /** - * @return bool|string - */ - public function displayPostEdit() - { - global $myts, $xoopsModuleConfig; - - if (empty($xoopsModuleConfig['recordedit_timelimit'])) { - return false; - } - - $post_edit = ''; - $post_edits = $this->getVar('post_edit'); - if (!empty($post_edits)) { - $post_edits = unserialize(base64_decode($post_edits)); - } - if (!isset($post_edits) || !is_array($post_edits)) { - $post_edits = array(); - } - if (is_array($post_edits) && count($post_edits) > 0) { - foreach ($post_edits as $postedit) { - $edit_time = (int)$postedit['edit_time']; - $edit_user = $myts->stripSlashesGPC($postedit['edit_user']); - $post_edit .= _MD_EDITEDBY . ' ' . $edit_user . ' ' . _MD_ON . ' ' . formatTimestamp((int)$edit_time) . '
    '; - } - } - - return $post_edit; - } - - /** - * @return array - */ - public function &getPostBody() - { - global $xoopsConfig, $xoopsModuleConfig, $xoopsUser, $myts; - require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.user.php'; - require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.render.php'; - - $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; - $karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma'); - $user_karma = $karmaHandler->getUserKarma(); - - $post = array(); - $post['attachment'] = false; - $post_text = newbb_displayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), - $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr')); - if (newbb_isAdmin($this->getVar('forum_id')) or $this->checkIdentity()) { - $post['text'] = $post_text . '
    ' . $this->displayAttachment(); - } elseif ($xoopsModuleConfig['enable_karma'] && $this->getVar('post_karma') > $user_karma) { - $post['text'] = sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')); - } elseif ($xoopsModuleConfig['allow_require_reply'] && $this->getVar('require_reply') - && (!$uid - || !isset($viewtopic_users[$uid])) - ) { - $post['text'] = _MD_REPLY_REQUIREMENT; - } else { - $post['text'] = $post_text . '
    ' . $this->displayAttachment(); - } - $memberHandler = xoops_getHandler('member'); - $eachposter = $memberHandler->getUser($this->getVar('uid')); - if (is_object($eachposter) && $eachposter->isActive()) { - if ($xoopsModuleConfig['show_realname'] && $eachposter->getVar('name')) { - $post['author'] = $eachposter->getVar('name'); - } else { - $post['author'] = $eachposter->getVar('uname'); - } - unset($eachposter); - } else { - $post['author'] = $this->getVar('poster_name') ?: $xoopsConfig['anonymous']; - } - - $post['subject'] = newbb_htmlspecialchars($this->vars['subject']['value']); - - $post['date'] = $this->getVar('post_time'); - - return $post; - } - - /** - * @return bool - */ - public function isTopic() - { - return !$this->getVar('pid'); - } - - /** - * @param string $action_tag - * @return bool - */ - public function checkTimelimit($action_tag = 'edit_timelimit') - { - require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.config.php'; - $newbb_config = newbb_loadConfig(); - if (empty($newbb_config['edit_timelimit'])) { - return true; - } - - return ($this->getVar('post_time') > time() - $newbb_config[$action_tag] * 60); - } - - /** - * @param int $uid - * @return bool - */ - public function checkIdentity($uid = -1) - { - global $xoopsUser; - - $uid = ($uid > -1) ? $uid : (is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0); - if ($this->getVar('uid') > 0) { - $user_ok = ($uid == $this->getVar('uid')) ? true : false; - } else { - static $user_ip; - if (!isset($user_ip)) { - $user_ip = newbb_getIP(); - } - $user_ok = ($user_ip == $this->getVar('poster_ip')) ? true : false; - } - - return $user_ok; - } - - // TODO: cleaning up and merge with post hanldings in viewpost.php - /** - * @param $isadmin - * @return array - */ - public function showPost($isadmin) - { - global $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsUser, $myts; - global $forumUrl, $forumImage; - global $viewtopic_users, $viewtopic_posters, $forum_obj, $topic_obj, $online, $user_karma, $viewmode, $order, $start, $total_posts, $topic_status; - static $post_NO = 0; - static $name_anonymous; - - if (!isset($name_anonymous)) { - $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); - } - - require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.time.php'; - require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.render.php'; - - $post_id = $this->getVar('post_id'); - $topic_id = $this->getVar('topic_id'); - $forum_id = $this->getVar('forum_id'); - - $query_vars = array('status', 'order', 'start', 'mode', 'viewmode'); - $query_array = array(); - $query_array['topic_id'] = "topic_id={$topic_id}"; - foreach ($query_vars as $var) { - if (!empty($_GET[$var])) { - $query_array[$var] = "{$var}={$_GET[$var]}"; - } - } - $page_query = htmlspecialchars(implode('&', array_values($query_array))); - - $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; - - ++$post_NO; - if (strtolower($order) === 'desc') { - $post_no = $total_posts - ($start + $post_NO) + 1; - } else { - $post_no = $start + $post_NO; - } - - if ($isadmin || $this->checkIdentity()) { - $post_text = $this->getVar('post_text'); - $post_attachment = $this->displayAttachment(); - } elseif ($xoopsModuleConfig['enable_karma'] && $this->getVar('post_karma') > $user_karma) { - $post_text = "
    " . sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '
    '; - $post_attachment = ''; - } elseif ($xoopsModuleConfig['allow_require_reply'] && $this->getVar('require_reply') - && (!$uid - || !in_array($uid, $viewtopic_posters)) - ) { - $post_text = "
    " . _MD_REPLY_REQUIREMENT . '
    '; - $post_attachment = ''; - } else { - $post_text = $this->getVar('post_text'); - $post_attachment = $this->displayAttachment(); - } - if (isset($viewtopic_users[$this->getVar('uid')])) { - $poster = $viewtopic_users[$this->getVar('uid')]; - } else { - $name = ($post_name = $this->getVar('poster_name')) ? $post_name : $name_anonymous; - $poster = array( - 'poster_uid' => 0, - 'name' => $name, - 'link' => $name - ); - } - - if ($posticon = $this->getVar('icon')) { - $post_image = ''; - } else { - $post_image = ''; - } - - $thread_buttons = array(); - - if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) { - /** @var NewbbTopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - $topic_status = $topic_obj->getVar('topic_status'); - if ($topicHandler->getPermission($forum_id, $topic_status, 'edit')) { - $edit_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit'))); - - if ($edit_ok) { - $thread_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT); - $thread_buttons['edit']['link'] = "edit.php?{$page_query}"; - $thread_buttons['edit']['name'] = _EDIT; - } - } - - if ($topicHandler->getPermission($forum_id, $topic_status, 'delete')) { - $delete_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit'))); - - if ($delete_ok) { - $thread_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE); - $thread_buttons['delete']['link'] = "delete.php?{$page_query}"; - $thread_buttons['delete']['name'] = _DELETE; - } - } - if ($topicHandler->getPermission($forum_id, $topic_status, 'reply')) { - $thread_buttons['reply']['image'] = newbb_displayImage('p_reply', _MD_REPLY); - $thread_buttons['reply']['link'] = "reply.php?{$page_query}"; - $thread_buttons['reply']['name'] = _MD_REPLY; - - $thread_buttons['quote']['image'] = newbb_displayImage('p_quote', _MD_QUOTE); - $thread_buttons['quote']['link'] = "reply.php?{$page_query}&quotedac=1"; - $thread_buttons['quote']['name'] = _MD_QUOTE; - } - } else { - $thread_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT); - $thread_buttons['edit']['link'] = "edit.php?{$page_query}"; - $thread_buttons['edit']['name'] = _EDIT; - - $thread_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE); - $thread_buttons['delete']['link'] = "delete.php?{$page_query}"; - $thread_buttons['delete']['name'] = _DELETE; - - $thread_buttons['reply']['image'] = newbb_displayImage('p_reply', _MD_REPLY); - $thread_buttons['reply']['link'] = "reply.php?{$page_query}"; - $thread_buttons['reply']['name'] = _MD_REPLY; - } - - if (!$isadmin && $xoopsModuleConfig['reportmod_enabled']) { - $thread_buttons['report']['image'] = newbb_displayImage('p_report', _MD_REPORT); - $thread_buttons['report']['link'] = "report.php?{$page_query}"; - $thread_buttons['report']['name'] = _MD_REPORT; - } - - $thread_action = array(); - - $post = array( - 'post_id' => $post_id, - 'post_parent_id' => $this->getVar('pid'), - 'post_date' => newbb_formatTimestamp($this->getVar('post_time')), - 'post_image' => $post_image, - 'post_title' => $this->getVar('subject'), - 'post_text' => $post_text, - 'post_attachment' => $post_attachment, - 'post_edit' => $this->displayPostEdit(), - 'post_no' => $post_no, - 'post_signature' => $this->getVar('attachsig') ? @$poster['signature'] : '', - 'poster_ip' => ($isadmin && $xoopsModuleConfig['show_ip']) ? long2ip($this->getVar('poster_ip')) : '', - 'thread_action' => $thread_action, - 'thread_buttons' => $thread_buttons, - 'poster' => $poster - ); - - unset($thread_buttons); - unset($eachposter); - - return $post; - } -} - -/** - * Class NewbbPostHandler - */ -class NewbbPostHandler extends XoopsPersistableObjectHandler -{ - /** - * @param null|XoopsDatabase $db - */ - public function __construct(XoopsDatabase $db) - { - parent::__construct($db, 'bb_posts', 'Post', 'post_id', 'subject'); - } - - /** - * @param mixed|null $id - * @return null|XoopsObject - */ - public function get($id) - { - $id = (int)$id; - $post = null; - $sql = 'SELECT p.*, t.* FROM ' - . $this->db->prefix('bb_posts') - . ' p LEFT JOIN ' - . $this->db->prefix('bb_posts_text') - . ' t ON p.post_id=t.post_id WHERE p.post_id=' - . $id; - if ($array = $this->db->fetchArray($this->db->query($sql))) { - $post = $this->create(false); - $post->assignVars($array); - } - - return $post; - } - - /** - * @param int $topic_id - * @param int $limit - * @param int $approved - * @return array - */ - public function &getByLimit($topic_id, $limit, $approved = 1) - { - $sql = 'SELECT p.*, t.*, tp.topic_status FROM ' - . $this->db->prefix('bb_posts') - . ' p LEFT JOIN ' - . $this->db->prefix('bb_posts_text') - . ' t ON p.post_id=t.post_id LEFT JOIN ' - . $this->db->prefix('bb_topics') - . ' tp ON tp.topic_id=p.topic_id WHERE p.topic_id=' - . $topic_id - . ' AND p.approved =' - . $approved - . ' ORDER BY p.post_time DESC'; - $result = $this->db->query($sql, $limit, 0); - $ret = array(); - while ($myrow = $this->db->fetchArray($result)) { - $post = $this->create(false); - $post->assignVars($myrow); - - $ret[$myrow['post_id']] = $post; - unset($post); - } - - return $ret; - } - - /** - * @param $post - * @return mixed - */ - public function getPostForPDF(&$post) - { - return $post->getPostBody(true); - } - - /** - * @param $post - * @return mixed - */ - public function getPostForPrint(&$post) - { - return $post->getPostBody(); - } - - /** - * @param $post - * @param bool $force - * @return bool - */ - public function approve(&$post, $force = false) - { - if (empty($post)) { - return false; - } - if (is_numeric($post)) { - $post = $this->get($post); - } else { - $post->unsetNew(); - } - $post_id = $post->getVar('post_id'); - $wasApproved = $post->getVar('approved'); - if (empty($force) && $wasApproved) { - return true; - } - $post->setVar('approved', 1); - $this->insert($post, true); - - /** @var NewbbTopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - $topic_obj = $topicHandler->get($post->getVar('topic_id')); - if ($topic_obj->getVar('topic_last_post_id') < $post->getVar('post_id')) { - $topic_obj->setVar('topic_last_post_id', $post->getVar('post_id')); - } - if ($post->isTopic()) { - $topic_obj->setVar('approved', 1); - } else { - $topic_obj->setVar('topic_replies', $topic_obj->getVar('topic_replies') + 1); - } - $topicHandler->insert($topic_obj, true); - - /** @var NewbbForumHandler $forumHandler */ - $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); - $forum_obj = $forumHandler->get($post->getVar('forum_id')); - if ($forum_obj->getVar('forum_last_post_id') < $post->getVar('post_id')) { - $forum_obj->setVar('forum_last_post_id', $post->getVar('post_id')); - } - $forum_obj->setVar('forum_posts', $forum_obj->getVar('forum_posts') + 1); - if ($post->isTopic()) { - $forum_obj->setVar('forum_topics', $forum_obj->getVar('forum_topics') + 1); - } - $forumHandler->insert($forum_obj, true); - - // Update user stats - if ($post->getVar('uid') > 0) { - $memberHandler = xoops_getHandler('member'); - $poster = $memberHandler->getUser($post->getVar('uid')); - if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) { - $poster->setVar('posts', $poster->getVar('posts') + 1); - $res = $memberHandler->insertUser($poster, true); - unset($poster); - } - } - - // Update forum stats - $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); - $statsHandler->update($post->getVar('forum_id'), 'post'); - if ($post->isTopic()) { - $statsHandler->update($post->getVar('forum_id'), 'topic'); - } - - return true; - } - - /** - * @param XoopsObject $post - * @param bool $force - * @return bool - */ - public function insert(XoopsObject $post, $force = true) - { - global $xoopsUser; - - // Set the post time - // The time should be "publish" time. To be adjusted later - if (!$post->getVar('post_time')) { - $post->setVar('post_time', time()); - } - - /** @var NewbbTopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - // Verify the topic ID - if ($topic_id = $post->getVar('topic_id')) { - $topic_obj = $topicHandler->get($topic_id); - // Invalid topic OR the topic is no approved and the post is not top post - if (!$topic_obj - // || (!$post->isTopic() && $topic_obj->getVar("approved") < 1) - ) { - return false; - } - } - if (empty($topic_id)) { - $post->setVar('topic_id', 0); - $post->setVar('pid', 0); - $post->setNew(); - $topic_obj = $topicHandler->create(); - } - $textHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Text'); - $post_text_vars = array('post_text', 'post_edit', 'dohtml', 'doxcode', 'dosmiley', 'doimage', 'dobr'); - if ($post->isNew()) { - if (!$topic_id = $post->getVar('topic_id')) { - $topic_obj->setVar('topic_title', $post->getVar('subject', 'n')); - $topic_obj->setVar('topic_poster', $post->getVar('uid')); - $topic_obj->setVar('forum_id', $post->getVar('forum_id')); - $topic_obj->setVar('topic_time', $post->getVar('post_time')); - $topic_obj->setVar('poster_name', $post->getVar('poster_name'), true); - $topic_obj->setVar('approved', $post->getVar('approved'), true); - if (!$topic_id = $topicHandler->insert($topic_obj, $force)) { - $post->deleteAttachment(); - $post->setErrors('insert topic error'); - - return false; - } - $post->setVar('topic_id', $topic_id); - - $pid = 0; - $post->setVar('pid', 0); - } elseif (!$post->getVar('pid')) { - $pid = $topicHandler->getTopPostId($topic_id); - $post->setVar('pid', $pid); - } - - $text_obj = $textHandler->create(); - foreach ($post_text_vars as $key) { - $text_obj->vars[$key] = $post->vars[$key]; - } - $post->destroyVars($post_text_vars); - if (!$post_id = parent::insert($post, $force)) { - return false; - } - $text_obj->setVar('post_id', $post_id); - if (!$textHandler->insert($text_obj, $force)) { - $this->delete($post); - $post->setErrors('post text insert error'); - - return false; - } - if ($post->getVar('approved') > 0) { - $this->approve($post, true); - } - $post->setVar('post_id', $post_id); - } else { - if ($post->isTopic()) { - if ($post->getVar('subject') != $topic_obj->getVar('topic_title')) { - $topic_obj->setVar('topic_title', $post->getVar('subject', 'n')); - } - if ($post->getVar('approved') != $topic_obj->getVar('approved')) { - $topic_obj->setVar('approved', $post->getVar('approved')); - } - if (!$result = $topicHandler->insert($topic_obj, $force)) { - $post->setErrors('update topic error'); - - return false; - } - } - $text_obj =& $textHandler->get($post->getVar('post_id')); - $text_obj->setDirty(); - foreach ($post_text_vars as $key) { - $text_obj->vars[$key] = $post->vars[$key]; - } - $post->destroyVars($post_text_vars); - if (!$post_id = parent::insert($post, $force)) { - return false; - } - if (!$textHandler->insert($text_obj, $force)) { - $post->setErrors('update post text error'); - - return false; - } - } - - return $post->getVar('post_id'); - } - - /** - * @param XoopsObject $post - * @param bool $isDeleteOne - * @param bool $force - * @return bool - */ - public function delete(XoopsObject $post, $isDeleteOne = true, $force = false) - { - if (!is_object($post) || $post->getVar('post_id') == 0) { - return false; - } - if ($isDeleteOne) { - if ($post->isTopic()) { - $criteria = new CriteriaCompo(new Criteria('topic_id', $post->getVar('topic_id'))); - $criteria->add(new Criteria('approved', 1)); - $criteria->add(new Criteria('pid', 0, '>')); - if ($this->getPostCount($criteria) > 0) { - return false; - } - } - - return $this->_delete($post, $force); - } else { - require_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; - $mytree = new XoopsTree($this->db->prefix('bb_posts'), 'post_id', 'pid'); - $arr = $mytree->getAllChild($post->getVar('post_id')); - for ($i = 0, $iMax = count($arr); $i < $iMax; ++$i) { - $childpost = $this->create(false); - $childpost->assignVars($arr[$i]); - $this->_delete($childpost, $force); - unset($childpost); - } - $this->_delete($post, $force); - } - - return true; - } - - /** - * @param $post - * @param bool $force - * @return bool - */ - public function _delete(&$post, $force = false) - { - global $xoopsModule; - - if (!is_object($post) || $post->getVar('post_id') == 0) { - return false; - } - - /* Set active post as deleted */ - if ($post->getVar('approved') > 0 && empty($force)) { - $sql = 'UPDATE ' . $this->db->prefix('bb_posts') . ' SET approved = -1 WHERE post_id = ' . $post->getVar('post_id'); - if (!$result = $this->db->queryF($sql)) { - } - /* delete pending post directly */ - } else { - $sql = sprintf('DELETE FROM %s WHERE post_id = %u', $this->db->prefix('bb_posts'), $post->getVar('post_id')); - if (!$result = $this->db->queryF($sql)) { - $post->setErrors('delte post error: ' . $sql); - - return false; - } - $post->deleteAttachment(); - - $sql = sprintf('DELETE FROM %s WHERE post_id = %u', $this->db->prefix('bb_posts_text'), $post->getVar('post_id')); - if (!$result = $this->db->queryF($sql)) { - $post->setErrors('Could not remove post text: ' . $sql); - - return false; - } - } - - if ($post->isTopic()) { - /** @var NewbbTopicHandler $topicHandler */ - $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); - $topic_obj = $topicHandler->get($post->getVar('topic_id')); - if ($topic_obj instanceof Topic) { - if (($topic_obj->getVar('approved') > 0) && empty($force)) { - $topiccount_toupdate = 1; - $topic_obj->setVar('approved', -1); - $topicHandler->insert($topic_obj); - xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id')); - } else { - if ($topic_obj->getVar('approved') > 0) { - xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id')); - } - $poll_id = $topic_obj->getVar('poll_id'); - if ($poll_id > 0) { - /** @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $poll_moduleHandler = $moduleHandler->getByDirname('xoopspoll'); - if (($poll_moduleHandler instanceof XoopsModuleHandler) && $poll_moduleHandler->isactive()) { - $pollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); - if (false !== $pollHandler->deleteAll(new Criteria('poll_id', $poll_id, '='))) { - $optionHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $optionHandler->deleteAll(new Criteria('poll_id', $poll_id, '=')); - $logHandler = xoops_getModuleHandler('log', 'xoopspoll'); - $logHandler->deleteAll(new Criteria('poll_id', $poll_id, '=')); - xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); - } - } - } - } - - $sql = sprintf('DELETE FROM %s WHERE topic_id = %u', $this->db->prefix('bb_topics'), $post->getVar('topic_id')); - if (!$result = $this->db->queryF($sql)) { - //xoops_error($this->db->error()); - } - $sql = sprintf('DELETE FROM %s WHERE topic_id = %u', $this->db->prefix('bb_votedata'), $post->getVar('topic_id')); - if (!$result = $this->db->queryF($sql)) { - //xoops_error($this->db->error()); - } - } - } else { - $sql = 'UPDATE ' . $this->db->prefix('bb_topics') . ' t - LEFT JOIN ' . $this->db->prefix('bb_posts') . ' p ON p.topic_id = t.topic_id - SET t.topic_last_post_id = p.post_id - WHERE t.topic_last_post_id = ' . $post->getVar('post_id') . ' - AND p.post_id = (SELECT MAX(post_id) FROM ' . $this->db->prefix('bb_posts') . ' WHERE topic_id=t.topic_id)'; - if (!$result = $this->db->queryF($sql)) { - } - } - - $postcount_toupdate = $post->getVar('approved'); - - if ($postcount_toupdate > 0) { - - // Update user stats - if ($post->getVar('uid') > 0) { - $memberHandler = xoops_getHandler('member'); - $poster = $memberHandler->getUser($post->getVar('uid')); - if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) { - $poster->setVar('posts', $poster->getVar('posts') - 1); - $res = $memberHandler->insertUser($poster, true); - unset($poster); - } - } - - $sql = 'UPDATE ' . $this->db->prefix('bb_posts') . ' SET pid = ' . $post->getVar('pid') . ' WHERE pid=' . $post->getVar('post_id'); - if (!$result = $this->db->queryF($sql)) { - //xoops_error($this->db->error()); - } - } - - return true; - } - - /** - * @param null $criteria - * @return int - */ - public function getPostCount($criteria = null) - { - return parent::getCount($criteria); - } - - /* - * TODO: combining viewtopic.php - */ - /** - * @param null $criteria - * @param int $limit - * @param int $start - * @param null $join - * @return array - */ - public function &getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join = null) - { - $ret = array(); - $sql = 'SELECT p.*, t.* ' - . ' FROM ' - . $this->db->prefix('bb_posts') - . ' AS p' - . ' LEFT JOIN ' - . $this->db->prefix('bb_posts_text') - . ' AS t ON t.post_id = p.post_id'; - if (!empty($join)) { - $sql .= $join; - } - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { - $sql .= ' ' . $criteria->renderWhere(); - if ($criteria->getSort() != '') { - $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); - } - } - $result = $this->db->query($sql, (int)$limit, (int)$start); - if (!$result) { - //xoops_error($this->db->error()); - return $ret; - } - while ($myrow = $this->db->fetchArray($result)) { - $post = $this->create(false); - $post->assignVars($myrow); - $ret[$myrow['post_id']] = $post; - unset($post); - } - - return $ret; - } - - /** - * clean orphan items from database - * - * @return bool true on success - */ - public function cleanOrphan() - { - global $xoopsDB; - $this->deleteAll(new Criteria('post_time', 0), true, true); - parent::cleanOrphan($this->db->prefix('bb_topics'), 'topic_id'); - parent::cleanOrphan($this->db->prefix('bb_posts_text'), 'post_id'); - - /* for MySQL 4.1+ */ - if (version_compare(mysqli_get_server_info($xoopsDB->conn), '4.1.0', 'ge')): - $sql = 'DELETE FROM ' . $this->db->prefix('bb_posts_text') . " WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM {$this->table}) )"; - else: - // for 4.0+ - /* */ - $sql = 'DELETE ' - . $this->db->prefix('bb_posts_text') - . ' FROM ' - . $this->db->prefix('bb_posts_text') - . " LEFT JOIN {$this->table} AS aa ON " - . $this->db->prefix('bb_posts_text') - . '.post_id = aa.post_id ' - . ' WHERE (aa.post_id IS NULL)'; - /* */ - // Alternative for 4.1+ - /* - $sql = "DELETE bb FROM ".$this->db->prefix("bb_posts_text")." AS bb". - " LEFT JOIN ".$this->table." AS aa ON bb.post_id = aa.post_id ". - " WHERE (aa.post_id IS NULL)"; - */ - endif; - if (!$result = $this->db->queryF($sql)) { - //xoops_error($this->db->error()); - return false; - } - - return true; - } - - /** - * clean expired objects from database - * - * @param int $expire time limit for expiration - * @return bool true on success - */ - public function cleanExpires($expire = 0) - { - $crit_expire = new CriteriaCompo(new Criteria('approved', 0, '<=')); - //if (!empty($expire)) { - $crit_expire->add(new Criteria('post_time', time() - (int)$expire, '<')); - - //} - return $this->deleteAll($crit_expire, true/*, true*/); - } -} diff --git a/extras/newbb_4x/trunk_4_00/index.html b/extras/newbb_4x/trunk_4_00/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/trunk_4_00/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/trunk_4_00/language/index.html b/extras/newbb_4x/trunk_4_00/language/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/trunk_4_00/language/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/trunk_4_00/language/main.php b/extras/newbb_4x/trunk_4_00/language/main.php deleted file mode 100644 index 128cfec..0000000 --- a/extras/newbb_4x/trunk_4_00/language/main.php +++ /dev/null @@ -1,496 +0,0 @@ -can access the forum.
    '); -define('_MD_CANNOT_ACCESS', 'You cannot access the forum.
    '); -define('_MD_CAN_POST', 'You can start a new topic.
    '); -define('_MD_CANNOT_POST', 'You cannot start a new topic.
    '); -define('_MD_CAN_VIEW', 'You can view topic.
    '); -define('_MD_CANNOT_VIEW', 'You cannot view topic.
    '); -define('_MD_CAN_REPLY', 'You can reply to posts.
    '); -define('_MD_CANNOT_REPLY', 'You cannot reply to posts.
    '); -define('_MD_CAN_EDIT', 'You can edit your posts.
    '); -define('_MD_CANNOT_EDIT', 'You cannot edit your posts.
    '); -define('_MD_CAN_DELETE', 'You can delete your posts.
    '); -define('_MD_CANNOT_DELETE', 'You cannot delete your posts.
    '); -define('_MD_CAN_ADDPOLL', 'You can add new polls.
    '); -define('_MD_CANNOT_ADDPOLL', 'You cannot add new polls.
    '); -define('_MD_CAN_VOTE', 'You can vote in polls.
    '); -define('_MD_CANNOT_VOTE', 'You cannot vote in polls.
    '); -define('_MD_CAN_ATTACH', 'You can attach files to posts.
    '); -define('_MD_CANNOT_ATTACH', 'You cannot attach files to posts.
    '); -define('_MD_CAN_NOAPPROVE', 'You can post without approval.
    '); -define('_MD_CANNOT_NOAPPROVE', 'You cannot post without approval.
    '); -define('_MD_CAN_TYPE', 'You can use topic type.
    '); -define('_MD_CANNOT_TYPE', 'You cannot use topic type.
    '); -define('_MD_CAN_HTML', 'You can use HTML syntax.
    '); -define('_MD_CANNOT_HTML', 'You cannot use HTML syntax.
    '); -define('_MD_CAN_UPLOAD', 'You can upload.
    '); -define('_MD_CANNOT_UPLOAD', 'You cannot upload.
    '); -define('_MD_CAN_SIGNATURE', 'You can use signature.
    '); -define('_MD_CANNOT_SIGNATURE', 'You cannot use signature.
    '); - -define('_MD_IMTOPICS', 'Important Topics'); -define('_MD_NOTIMTOPICS', 'Forum Topics'); -define('_MD_FORUMOPTION', 'Forum options'); - -define('_MD_VAUP', 'View all unreplied posts'); -define('_MD_VANP', 'View all new posts'); - -define('_MD_UNREPLIED', 'unreplied topics'); -define('_MD_UNREAD', 'unread topics'); -define('_MD_ALL', 'all topics'); -define('_MD_ALLPOSTS', 'all posts'); -define('_MD_VIEW', 'View'); - -//viewtopic.php -define('_MD_AUTHOR', 'Author'); -define('_MD_LOCKTOPIC', 'Lock this topic'); -define('_MD_UNLOCKTOPIC', 'Unlock this topic'); -define('_MD_UNSTICKYTOPIC', 'Make this topic UnSticky'); -define('_MD_STICKYTOPIC', 'Make this topic Sticky'); -define('_MD_DIGESTTOPIC', 'Make this topic as Digest'); -define('_MD_UNDIGESTTOPIC', 'Make this topic as UnDigest'); -define('_MD_MERGETOPIC', 'Merge this topic'); -define('_MD_MOVETOPIC', 'Move this topic'); -define('_MD_DELETETOPIC', 'Delete this topic'); -define('_MD_TOP', 'Top'); -define('_MD_BOTTOM', 'Bottom'); -define('_MD_PREVTOPIC', 'Previous Topic'); -define('_MD_NEXTTOPIC', 'Next Topic'); -define('_MD_GROUP', 'Group:'); -define('_MD_QUICKREPLY', 'Quick Reply'); -define('_MD_POSTREPLY', 'Post Reply'); -define('_MD_PRINTTOPICS', 'Print Topic'); -define('_MD_PRINT', 'Print'); -define('_MD_REPORT', 'Report'); -define('_MD_PM', 'PM'); -define('_MD_EMAIL', 'Email'); -define('_MD_WWW', 'WWW'); -define('_MD_AIM', 'AIM'); -define('_MD_YIM', 'YIM'); -define('_MD_MSNM', 'MSNM'); -define('_MD_ICQ', 'ICQ'); -define('_MD_PRINT_TOPIC_LINK', 'URL for this discussion'); -define('_MD_ADDTOLIST', 'Add to your Contact List'); -define('_MD_TOPICOPT', 'Topic options'); -define('_MD_VIEWMODE', 'View mode'); -define('_MD_NEWEST', 'Newest First'); -define('_MD_OLDEST', 'Oldest First'); - -define('_MD_FORUMSEARCH', 'Search Forum'); - -define('_MD_RATED', 'Rated:'); -define('_MD_RATE', 'Rate Thread'); -define('_MD_RATEDESC', 'Rate this Thread'); -define('_MD_RATING', 'Vote now'); -define('_MD_RATE1', 'Terrible'); -define('_MD_RATE2', 'Bad'); -define('_MD_RATE3', 'Average'); -define('_MD_RATE4', 'Good'); -define('_MD_RATE5', 'Excellent'); - -define('_MD_TOPICOPTION', 'Topic options'); -define('_MD_KARMA_REQUIREMENT', 'Your personal karm %s does not reach the required karma %s.
    Please try later.'); -define('_MD_REPLY_REQUIREMENT', 'To view this post, you must login and reply first.'); -define('_MD_TOPICOPTIONADMIN', 'Topic Admin options'); -define('_MD_POLLOPTIONADMIN', 'Poll Admin options'); - -define('_MD_EDITPOLL', 'Edit this Poll'); -define('_MD_DELETEPOLL', 'Delete this Poll'); -define('_MD_RESTARTPOLL', 'Restart this Poll'); -define('_MD_ADDPOLL', 'Add Poll'); - -define('_MD_QUICKREPLY_EMPTY', 'Enter a quick reply here'); - -define('_MD_LEVEL', 'Level :'); -define('_MD_HP', 'HP :'); -define('_MD_MP', 'MP :'); -define('_MD_EXP', 'EXP :'); - -define('_MD_BROWSING', 'Browsing this Thread:'); -define('_MD_POSTTONEWS', 'Send this post to a news Story'); - -define('_MD_EXCEEDTHREADVIEW', 'Post count exceeds the threshold for thread mode
    Changing to flat mode'); - -//forumform.inc -//define('_MD_PRIVATE', 'This is a Private forum.
    Only users with special access can post new topics and replies to this forum'); -define('_MD_QUOTE', 'Quote'); -define('_MD_VIEW_REQUIRE', 'View requirements'); -define('_MD_REQUIRE_KARMA', 'Karma'); -define('_MD_REQUIRE_REPLY', 'Reply'); -define('_MD_REQUIRE_NULL', 'No requirement'); - -define('_MD_SELECT_FORMTYPE', 'Select your desired form type'); - -define('_MD_FORM_COMPACT', 'Compact'); -define('_MD_FORM_DHTML', 'DHTML'); -define('_MD_FORM_SPAW', 'Spaw Editor'); -define('_MD_FORM_HTMLAREA', 'HTMLArea'); -define('_MD_FORM_FCK', 'FCK Editor'); -define('_MD_FORM_KOIVI', 'Koivi Editor'); -define('_MD_FORM_TINYMCE', 'TinyMCE Editor'); - -// ERROR messages -define('_MD_ERRORFORUM', 'ERROR: Forum not selected!'); -define('_MD_ERRORPOST', 'ERROR: Post not selected!'); -define('_MD_NORIGHTTOVIEW', 'You don\'t have the right to view this topic.'); -define('_MD_NORIGHTTOPOST', 'You don\'t have the right to post in this forum.'); -define('_MD_NORIGHTTOEDIT', 'You don\'t have the right to edit in this forum.'); -define('_MD_NORIGHTTOREPLY', 'You don\'t have the right to reply in this forum.'); -define('_MD_NORIGHTTOACCESS', 'You don\'t have the right to access this forum.'); -define('_MD_ERRORTOPIC', 'ERROR: Topic not selected!'); -define('_MD_ERRORCONNECT', 'ERROR: Could not connect to the forums database.'); -define('_MD_ERROREXIST', 'ERROR: The forum you selected does not exist. Please go back and try again.'); -define('_MD_ERROROCCURED', 'An Error Occured'); -define('_MD_COULDNOTQUERY', 'Could not query the forums database.'); -define('_MD_FORUMNOEXIST', 'Error - The forum/topic you selected does not exist. Please go back and try again.'); -define('_MD_USERNOEXIST', 'That user does not exist. Please go back and search again.'); -define('_MD_COULDNOTREMOVE', 'Error - Could not remove posts from the database!'); -define('_MD_COULDNOTREMOVETXT', 'Error - Could not remove post texts!'); -define('_MD_TIMEISUP', 'Your have reach the timelimit for editing your post.'); -define('_MD_TIMEISUPDEL', 'Your have reach the timelimit for deleting your post.'); - -//reply.php -define('_MD_ON', 'on'); //Posted on -define('_MD_USERWROTE', '%s wrote:'); // %s is username -define('_MD_RE', 'Re'); - -//post.php -define('_MD_EDITNOTALLOWED', 'You\'re not allowed to edit this post!'); -define('_MD_EDITEDBY', 'Edited by'); -define('_MD_ANONNOTALLOWED', 'Anonymous users are not allowed to post.
    Please register.'); -define('_MD_THANKSSUBMIT', 'Thanks for your submission!'); -define('_MD_REPLYPOSTED', 'A reply to your topic has been posted.'); -define('_MD_HELLO', 'Hello %s,'); -define('_MD_URRECEIVING', 'You are receiving this email because a message you posted on %s forums has been replied to.'); // %s is your site name -define('_MD_CLICKBELOW', 'Click on the link below to view the thread:'); -define('_MD_WAITFORAPPROVAL', 'Thank you. Your post will be approved before publication.'); -define('_MD_POSTING_LIMITED', 'Why not take a break and come back in %d sec'); - -//forumform.inc -define('_MD_NAMEMAIL', 'Name/Email:'); -define('_MD_LOGOUT', 'Logout'); -define('_MD_REGISTER', 'Register'); -define('_MD_SUBJECTC', 'Subject:'); -define('_MD_MESSAGEICON', 'Message Icon:'); -define('_MD_MESSAGEC', 'Message:'); -define('_MD_ALLOWEDHTML', 'Allowed HTML:'); -define('_MD_OPTIONS', 'Options:'); -define('_MD_POSTANONLY', 'Post Anonymously'); -define('_MD_DOSMILEY', 'Enable Smiley'); -define('_MD_DOXCODE', 'Enable Xoops Code'); -define('_MD_DOBR', 'Enable line break (Suggest to turn off if HTML enabled)'); -define('_MD_DOHTML', 'Enable html tags'); -define('_MD_NEWPOSTNOTIFY', 'Notify me of new posts in this thread'); -define('_MD_ATTACHSIG', 'Attach Signature'); -define('_MD_POST', 'Post'); -define('_MD_SUBMIT', 'Submit'); -define('_MD_CANCELPOST', 'Cancel Post'); -define('_MD_REMOVE', 'Remove'); -define('_MD_UPLOAD', 'Upload'); - -// forumuserpost.php -define('_MD_ADD', 'Add'); -define('_MD_REPLY', 'Reply'); - -// topicmanager.php -define('_MD_VIEWTHETOPIC', 'View the topic'); -define('_MD_RETURNTOTHEFORUM', 'Return to the forum'); -define('_MD_RETURNFORUMINDEX', 'Return to the forum index'); -define('_MD_ERROR_BACK', 'Error - Please go back and try again.'); -define('_MD_GOTONEWFORUM', 'View the updated topic'); - -define('_MD_TOPICDELETE', 'The topic has been deleted.'); -define('_MD_TOPICMERGE', 'The topic has been merged.'); -define('_MD_TOPICMOVE', 'The topic has been moved.'); -define('_MD_TOPICLOCK', 'The topic has been locked.'); -define('_MD_TOPICUNLOCK', 'The topic has been unlocked.'); -define('_MD_TOPICSTICKY', 'The topic has been Stickyed.'); -define('_MD_TOPICUNSTICKY', 'The topic has been unStickyed.'); -define('_MD_TOPICDIGEST', 'The topic has been Digested.'); -define('_MD_TOPICUNDIGEST', 'The topic has been unDigested.'); - -define('_MD_DELETE', 'Delete'); -define('_MD_MOVE', 'Move'); -define('_MD_MERGE', 'Merge'); -define('_MD_LOCK', 'Lock'); -define('_MD_UNLOCK', 'unLock'); -define('_MD_STICKY', 'Sticky'); -define('_MD_UNSTICKY', 'unSticky'); -define('_MD_DIGEST', 'Digest'); -define('_MD_UNDIGEST', 'unDigest'); - -define('_MD_DESC_DELETE', 'Once you press the delete button at the bottom of this form the topic you have selected, and all its related posts, will be permanently removed.'); -define('_MD_DESC_MOVE', 'Once you press the move button at the bottom of this form the topic you have selected, and its related posts, will be moved to the forum you have selected.'); -define('_MD_DESC_MERGE', - 'Once you press the merge button at the bottom of this form the topic you have selected, and its related posts, will be merged to the topic you have selected.
    The destination topic ID must be smaller than current one.'); -define('_MD_DESC_LOCK', 'Once you press the lock button at the bottom of this form the topic you have selected will be locked. You may unlock it at a later time if you like.'); -define('_MD_DESC_UNLOCK', 'Once you press the unlock button at the bottom of this form the topic you have selected will be unlocked. You may lock it again at a later time if you like.'); -define('_MD_DESC_STICKY', 'Once you press the Sticky button at the bottom of this form the topic you have selected will be Stickyed. You may unSticky it again at a later time if you like.'); -define('_MD_DESC_UNSTICKY', 'Once you press the unSticky button at the bottom of this form the topic you have selected will be unStickyed. You may Sticky it again at a later time if you like.'); -define('_MD_DESC_DIGEST', 'Once you press the Digest button at the bottom of this form the topic you have selected will be Digested. You may unDigest it again at a later time if you like.'); -define('_MD_DESC_UNDIGEST', 'Once you press the unDigest button at the bottom of this form the topic you have selected will be unDigested. You may Digest it again at a later time if you like.'); - -define('_MD_MERGETOPICTO', 'Merge Topic To:'); -define('_MD_MOVETOPICTO', 'Move Topic To:'); -define('_MD_NOFORUMINDB', 'No Forums in DB'); - -// delete.php -define('_MD_DELNOTALLOWED', 'Sorry, but you\'re not allowed to delete this post.'); -define('_MD_AREUSUREDEL', 'Are you sure you want to delete this post and all its child posts?'); -define('_MD_POSTSDELETED', 'Selected post and all its child posts deleted.'); -define('_MD_POSTDELETED', 'Selected post deleted.'); - -// definitions moved from global. -define('_MD_THREAD', 'Thread'); -define('_MD_FROM', 'From'); -define('_MD_JOINED', 'Joined'); -define('_MD_ONLINE', 'Online'); -define('_MD_OFFLINE', 'Offline'); -define('_MD_FLAT', 'Flat'); - -// online.php -define('_MD_USERS_ONLINE', 'Users Online:'); -define('_MD_ANONYMOUS_USERS', 'Anonymous Users'); -define('_MD_REGISTERED_USERS', 'Registered Users: '); -define('_MD_BROWSING_FORUM', 'Users browsing forum'); -define('_MD_TOTAL_ONLINE', 'Total %d Users Online.'); -define('_MD_ADMINISTRATOR', 'Administrator'); - -define('_MD_NO_SUCH_FILE', 'File not exist!'); -//define('_MD_ERROR_UPATEATTACHMENT', 'Error occur when updating attachment'); - -// ratethread.php -define('_MD_CANTVOTEOWN', 'You cannot vote on the topic you submitted.
    All votes are logged and reviewed.'); -define('_MD_VOTEONCE', 'Please do not vote for the same topic more than once.'); -define('_MD_VOTEAPPRE', 'Your vote is appreciated.'); -define('_MD_THANKYOU', 'Thank you for taking the time to vote here at %s'); // %s is your site name -define('_MD_VOTES', 'Votes'); -define('_MD_NOVOTERATE', 'You did not rate this Topic'); - -// polls.php -define('_MD_POLL_DBUPDATED', 'Database Updated Successfully!'); -define('_MD_POLL_POLLCONF', 'Polls Configuration'); -define('_MD_POLL_POLLSLIST', 'Polls List'); -define('_MD_POLL_AUTHOR', 'Author of this poll'); -define('_MD_POLL_DISPLAYBLOCK', 'Display in block?'); -define('_MD_POLL_POLLQUESTION', 'Poll Question'); -define('_MD_POLL_VOTERS', 'Total voters'); -define('_MD_POLL_VOTES', 'Total votes'); -define('_MD_POLL_EXPIRATION', 'Expiration'); -define('_MD_POLL_EXPIRED', 'Expired'); -define('_MD_POLL_VIEWLOG', 'View log'); -define('_MD_POLL_CREATNEWPOLL', 'Create new poll'); -define('_MD_POLL_POLLDESC', 'Poll description'); -define('_MD_POLL_DISPLAYORDER', 'Display order'); -define('_MD_POLL_ALLOWMULTI', 'Allow multiple selections?'); -define('_MD_POLL_NOTIFY', 'Notify the poll author when expired?'); -define('_MD_POLL_POLLOPTIONS', 'Options'); -define('_MD_POLL_EDITPOLL', 'Edit poll'); -define('_MD_POLL_FORMAT', 'Format: yyyy-mm-dd hh:mm:ss'); -define('_MD_POLL_CURRENTTIME', 'Current time is %s'); -define('_MD_POLL_EXPIREDAT', 'Expired at %s'); -define('_MD_POLL_RESTART', 'Restart this poll'); -define('_MD_POLL_ADDMORE', 'Add more options'); -define('_MD_POLL_RUSUREDEL', 'Are you sure you want to delete this poll and all its comments?'); -define('_MD_POLL_RESTARTPOLL', 'Restart poll'); -define('_MD_POLL_RESET', 'Reset all logs for this poll?'); -define('_MD_POLL_ADDPOLL', 'Add Poll'); -define('_MD_POLLMODULE_ERROR', 'xoopspoll module not available for use'); -define('_MD_VIEW_LOG', 'View Log'); -define('_MD_LOG_NOT_IMPLEMENTED', 'Sorry, not yet'); -define('_MD_LOG_XOOPSPOLL_ADMIN_REDIRECT', 'Redirecting to Xoopspoll Administration'); - -//report.php -define('_MD_REPORTED', 'Thank you for reporting this post/thread! A moderator will look into your report shortly.'); -define('_MD_REPORT_ERROR', 'Error occured while sending the report.'); -define('_MD_REPORT_TEXT', 'Report message:'); - -define('_MD_PDF', 'Create PDF from Post'); -define('_MD_PDF_PAGE', 'Page %s'); - -//print.php -define('_MD_COMEFROM', 'This Post was from:'); - -//viewpost.php -define('_MD_VIEWALLPOSTS', 'All Posts'); -define('_MD_VIEWTOPIC', 'Topic'); -define('_MD_VIEWFORUM', 'Forum'); - -define('_MD_COMPACT', 'Compact'); - -define('_MD_MENU_SELECT', 'Selection'); -define('_MD_MENU_HOVER', 'Hover'); -define('_MD_MENU_CLICK', 'Click'); - -define('_MD_WELCOME_SUBJECT', '%s has joined the forum'); -define('_MD_WELCOME_MESSAGE', 'Hi, %s has joined you. Let\'s start ...'); - -define('_MD_VIEWNEWPOSTS', 'View new posts'); - -define('_MD_INVALID_SUBMIT', 'Invalid submission. You could have exceeded session time. Please re-submit or make a backup of your post and login to resubmit if necessary.'); - -define('_MD_ACCOUNT', 'Account'); -define('_MD_NAME', 'Name'); -define('_MD_PASSWORD', 'Password'); -define('_MD_LOGIN', 'Login'); - -/* -define('_MD_TRANSFER', 'Transfer'); -define('_MD_TRANSFER_DESC', 'Transfer the post to other applications'); -define('_MD_TRANSFER_DONE', 'The action is done successully: %s'); -*/ - -define('_MD_APPROVE', 'Approve'); -define('_MD_RESTORE', 'Restore'); -define('_MD_SPLIT_ONE', 'Split'); -define('_MD_SPLIT_TREE', 'Split all children'); -define('_MD_SPLIT_ALL', 'Split all'); - -define('_MD_TYPE_ADMIN', 'Admin mode'); -define('_MD_TYPE_VIEW', 'View mode'); -define('_MD_TYPE_PENDING', 'Pending'); -define('_MD_TYPE_DELETED', 'Deleted'); -define('_MD_TYPE_SUSPEND', 'Suspension'); - -define('_MD_DBUPDATED', 'Database Updated Successfully!'); - -define('_MD_SUSPEND_SUBJECT', 'User %s is suspended for %d days'); -define('_MD_SUSPEND_TEXT', 'User %s is suspended for %d days due to:
    [quote]%s[/quote]

    The suspension is valid till %s'); -define('_MD_SUSPEND_UID', 'User ID'); -define('_MD_SUSPEND_IP', 'IP segments (full or segments)'); -define('_MD_SUSPEND_DURATION', 'Suspension duration (Days)'); -define('_MD_SUSPEND_DESC', 'Suspension reason'); -define('_MD_SUSPEND_LIST', 'Suspension list'); -define('_MD_SUSPEND_START', 'Start'); -define('_MD_SUSPEND_EXPIRE', 'End'); -define('_MD_SUSPEND_SCOPE', 'Scope'); -define('_MD_SUSPEND_MANAGEMENT', 'Moderation management'); -define('_MD_SUSPEND_NOACCESS', 'Your ID or IP has been suspended'); - -define('_MD_NEWBB_TYPE', 'Topic type'); - -//define("_MD_NEWBB_TAG", "Tag"); -/* -// !!IMPORTANT!! insert '\' before any char among reserved chars: "a", "A", "B", "c", "d", "D", "F", "g", "G", "h", "H", "i", "I", "j", "l", "L", "m", "M", "n", "O", "r", "s", "S", "t", "T", "U", "w", "W", "Y", "y", "z", "Z" -// insert double '\' before 't', 'r', 'n' -define('_MD_TODAY', '\T\o\d\a\y G:i:s'); -define('_MD_YESTERDAY', '\Y\e\s\\t\e\\r\d\a\y G:i:s'); -define('_MD_MONTHDAY', 'n/j G:i:s'); -define('_MD_YEARMONTHDAY', 'Y/n/j G:i'); -*/ diff --git a/extras/newbb_4x/trunk_4_00/polls.php b/extras/newbb_4x/trunk_4_00/polls.php deleted file mode 100644 index 7890816..0000000 --- a/extras/newbb_4x/trunk_4_00/polls.php +++ /dev/null @@ -1,400 +0,0 @@ - - */ - -include_once $GLOBALS['xoops']->path('header.php'); - -include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); -include_once $GLOBALS['xoops']->path('class/xoopslists.php'); -include_once $GLOBALS['xoops']->path('class/xoopsblock.php'); -xoops_load('XoopsRequest'); - -// irmtfan correct the way and typo=addmor -> addmore -$op = 'add'; -$goodOps = array( - 'add', - 'save', - 'edit', - 'update', - 'addmore', - 'savemore', - 'delete', - 'delete_ok', - 'restart', - 'restart_ok', - 'log' -); -$op = XoopsRequest::getString('op', 'add'); -$op = (!in_array($op, $goodOps)) ? 'add' : $op; - -//$poll_id = (isset($_GET['poll_id'])) ? (int)($_GET['poll_id']) : 0; -//$poll_id = (isset($_POST['poll_id'])) ? (int)($_POST['poll_id']) : $poll_id; -$poll_id = XoopsRequest::getInt('poll_id', XoopsRequest::getInt('poll_id', 0, 'POST'), 'GET'); -//$topic_id = (isset($_GET['topic_id'])) ? (int)($_GET['topic_id']) : 0; -//$topic_id = (isset($_POST['topic_id'])) ? (int)($_POST['topic_id']) : $topic_id; -$topic_id = XoopsRequest::getInt('topic_id', XoopsRequest::getInt('topic_id', 0, 'POST'), 'GET'); -/** @var XoopsModuleHandler $moduleHandler */ -$moduleHandler = xoops_getHandler('module'); -$xoopspoll = $moduleHandler->getByDirname('xoopspoll'); -if (is_object($xoopspoll) && $xoopspoll->getVar('isactive')) { - xoops_load('constants', 'xoopspoll'); - xoops_load('pollUtility', 'xoopspoll'); - xoops_load('XoopsRequest'); - xoops_loadLanguage('admin', 'xoopspoll'); - $xpPollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); -} else { - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_POLLMODULE_ERROR); -} - -/** @var NewbbTopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); -$topic_obj = $topicHandler->get($topic_id); -if ($topic_obj instanceof Topic) { - $forum_id = $topic_obj->getVar('forum_id'); -} else { - redirect_header('index.php', 2, _MD_POLLMODULE_ERROR . ': ' . _MD_FORUMNOEXIST); -} - -/** @var NewbbForumHandler $forumHandler */ -$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); -$forum_obj = $forumHandler->get($forum_id); -if (!$forumHandler->getPermission($forum_obj)) { - redirect_header('index.php', 2, _MD_NORIGHTTOACCESS); -} - -if (!$topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'view')) { - redirect_header('viewforum.php?forum=' . $forum_obj->getVar('forum_id'), 2, _MD_NORIGHTTOVIEW); -} - -if (!newbb_isAdmin($forum_obj)) { - $perm = false; - if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'addpoll') - //&& $forum_obj->getVar('allow_polls') == 1 { - ) { - if (('add' === $op || 'save' === $op || 'update' === $op) - && !$topic_obj->getVar('topic_haspoll') - && ($GLOBALS['xoopsUser'] instanceof XoopsUser) - && ($GLOBALS['xoopsUser']->getVar('uid') === $topic_obj->getVar('topic_poster')) - ) { - $perm = true; - } elseif (!empty($poll_id) && ($GLOBALS['xoopsUser'] instanceof XoopsUser)) { - $poll_obj = $xpPollHandler->get($poll_id); - if ($GLOBALS['xoopsUser']->getVar('uid') === $poll_obj->getVar('user_id')) { - $perm = true; - } - unset($poll_obj); - } - } - if (!$perm) { - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _NOPERM); - } -} - -switch ($op) { - case 'add': - case 'edit': - echo '

    ' . _MD_POLL_EDITPOLL . "

    \n"; - $poll_obj = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist - $poll_obj->renderForm($_SERVER['PHP_SELF'], 'post', array('topic_id' => $topic_id)); - break; - - case 'save': - case 'update': - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - - /* make sure there's at least one option */ - $option_text = isset($_POST['option_text']) ? $_POST['option_text'] : ''; - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; - $option_string = trim($option_string); - if (empty($option_string)) { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLOPTIONS . ' !'); - } - - $poll_obj = $xpPollHandler->get($poll_id); - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - - $notify = XoopsRequest::getInt('notify', XoopspollConstants::NOTIFICATION_ENABLED, 'POST'); - - $currentTimestamp = time(); - $xuEndTimestamp = strtotime(XoopsRequest::getString('xu_end_time', null, 'POST')); - $endTimestamp = empty($_POST['xu_end_time']) ? ($currentTimestamp + XoopspollConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); - $xuStartTimestamp = strtotime(XoopsRequest::getString('xu_start_time', null, 'POST')); - $startTimestamp = empty($_POST['xu_start_time']) ? ($endTimestamp - XoopspollConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); - - // don't allow changing start time if there are votes in the log - if (($startTimestamp < $poll_obj->getVar('start_time')) - && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0) - ) { - $startTimestamp = $poll_obj->getVar('start_time'); //don't change start time - } - - $poll_vars = array( - 'user_id' => XoopsRequest::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), - 'question' => XoopsRequest::getString('question', null, 'POST'), - 'description' => XoopsRequest::getText('description', null, 'POST'), - 'mail_status' => (XoopspollConstants::NOTIFICATION_ENABLED === $notify) ? XoopspollConstants::POLL_NOT_MAILED : XoopspollConstants::POLL_MAILED, - 'mail_voter' => XoopsRequest::getInt('mail_voter', XoopspollConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), - 'start_time' => $startTimestamp, - 'end_time' => $endTimestamp, - 'display' => XoopsRequest::getInt('display', XoopspollConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), - 'visibility' => XoopsRequest::getInt('visibility', XoopspollConstants::HIDE_NEVER, 'POST'), - 'weight' => XoopsRequest::getInt('weight', XoopspollConstants::DEFAULT_WEIGHT, 'POST'), - 'multiple' => XoopsRequest::getInt('multiple', XoopspollConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), - 'multilimit' => XoopsRequest::getInt('multilimit', XoopspollConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), - 'anonymous' => XoopsRequest::getInt('anonymous', XoopspollConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST') - ); - $poll_obj->setVars($poll_vars); - $poll_id = $xpPollHandler->insert($poll_obj); - if (!$poll_id) { - $err = $poll_obj->getHtmlErrors(); - exit($err); - } - - // now get the options - $optionIdArray = XoopsRequest::getArray('option_id', array(), 'POST'); - $optionIdArray = array_map('intval', $optionIdArray); - $optionTextArray = XoopsRequest::getArray('option_text', array(), 'POST'); - $optionColorArray = XoopsRequest::getArray('option_color', array(), 'POST'); - - foreach ($optionIdArray as $key => $oId) { - if (!empty($oId) && ($option_obj = $xpOptHandler->get($oId))) { - // existing option object so need to update it - $optionTextArray[$key] = trim($optionTextArray[$key]); - if ('' === $optionTextArray[$key]) { - // want to delete this option - if (false !== $xpOptHandler->delete($option_obj)) { - // now remove it from the log - $xpLogHandler->deleteByOptionId($option_obj->getVar('option_id')); - //update vote count in poll - $xpPollHandler->updateCount($poll_obj); - } else { - xoops_error($xpLogHandler->getHtmlErrors()); - break; - } - } else { - $option_obj->setVar('option_text', $optionTextArray[$key]); - $option_obj->setVar('option_color', $optionColorArray[$key]); - $option_obj->setVar('poll_id', $poll_id); - $xpOptHandler->insert($option_obj); - } - } else { - // new option object - $option_obj = $xpOptHandler->create(); - $optionTextArray[$key] = trim($optionTextArray[$key]); - if ('' !== $optionTextArray[$key]) { // ignore if text is empty - $option_obj->setVar('option_text', $optionTextArray[$key]); - $option_obj->setVar('option_color', $optionColorArray[$key]); - $option_obj->setVar('poll_id', $poll_id); - $xpOptHandler->insert($option_obj); - } - unset($option_obj); - } - } - - // clear the template cache so changes take effect immediately - include_once $GLOBALS['xoops']->path('class/template.php'); - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - - // update topic to indicate it has a poll - $topic_obj->setVar('topic_haspoll', 1); - $topic_obj->setVar('poll_id', $poll_obj->getVar('poll_id')); - $success = $topicHandler->insert($topic_obj); - if (!$success) { - xoops_error($topicHandler->getHtmlErrors()); - } else { - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_POLL_DBUPDATED); - } - break; - - case 'addmore': - $poll_obj = $xpPollHandler->get($poll_id); - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $question = $poll_obj->getVar('question'); - unset($poll_obj); - $poll_form = new XoopsThemeForm(_MD_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); - $poll_form->addElement(new XoopsFormLabel(_MD_POLL_POLLQUESTION, $question)); - $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); - $poll_form->addElement($option_tray); - $poll_form->addElement(new XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); - $poll_form->addElement(new XoopsFormHidden('op', 'savemore')); - $poll_form->addElement(new XoopsFormHidden('topic_id', $topic_id)); - $poll_form->addElement(new XoopsFormHidden('poll_id', $poll_id)); - - echo '

    ' . _MD_POLL_POLLCONF . "

    \n"; - $poll_form->display(); - break; - - case 'savemore': - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - - $option_text = isset($_POST['option_text']) ? $_POST['option_text'] : ''; - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; - $option_string = trim($option_string); - if (empty($option_string)) { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLOPTIONS . ' !'); - } - - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $i = 0; - $option_color = empty($_POST['option_color']) ? null : $_POST['option_color']; - foreach ($option_text as $optxt) { - $optxt = trim($optxt); - if ('' !== $optxt) { - $option_obj = $xpOptHandler->create(); - $option_obj->setVar('option_text', $optxt); - $option_obj->setVar('poll_id', $poll_id); - $option_obj->setVar('option_color', $option_color[$i]); - $xpOptHandler->insert($option_obj); - unset($option_obj); - } - ++$i; - } - include_once $GLOBALS['xoops']->path('class/template.php'); - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - redirect_header("polls.php?op=edit&poll_id={$poll_id}&topic_id={$topic_id}", 2, _MD_POLL_DBUPDATED); - break; - - case 'delete': - echo '

    ' . _MD_POLL_POLLCONF . "

    \n"; - $poll_obj = $xpPollHandler->get($poll_id); - xoops_confirm(array('op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id), 'polls.php', sprintf(_MD_POLL_RUSUREDEL, $poll_obj->getVar('question'))); - break; - - case 'delete_ok': - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - //try and delete the poll - $poll_obj = $xpPollHandler->get($poll_id); - $status = $xpPollHandler->delete($poll_obj); - if (false !== $status) { - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - $xpOptHandler->deleteByPollId($poll_id); - $xpLogHandler->deleteByPollId($poll_id); - } else { - $msg = $xpPollHandler->getHtmlErrors(); - } - if (false !== $status) { - include_once $GLOBALS['xoops']->path('class/template.php'); - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - // delete comments for this poll - xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); - - $topic_obj->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone - $topic_obj->setVar('topic_haspoll', 0); - $topic_obj->setVar('poll_id', 0); - $success = $topicHandler->insert($topic_obj); - if (!$success) { - xoops_error($topicHandler->getHtmlErrors()); - break; - } - } else { - xoops_error($msg); - break; - } - redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_DBUPDATED); - break; - - case 'restart': - $default_poll_duration = XoopspollConstants::DEFAULT_POLL_DURATION; - $poll_form = new XoopsThemeForm(_MD_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); - $expire_text = new XoopsFormText(_MD_POLL_EXPIRATION . '
    ' . _MD_POLL_FORMAT . '
    ' . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), _DATESTRING)) . '
    ', 'end_time', 20, 19, - formatTimestamp(time() + $default_poll_duration, _DATESTRING)); - $poll_form->addElement($expire_text); - $poll_form->addElement(new XoopsFormRadioYN(_MD_POLL_NOTIFY, 'notify', 1)); - $poll_form->addElement(new XoopsFormRadioYN(_MD_POLL_RESET, 'reset', 0)); - $poll_form->addElement(new XoopsFormHidden('op', 'restart_ok')); - $poll_form->addElement(new XoopsFormHidden('topic_id', $topic_id)); - $poll_form->addElement(new XoopsFormHidden('poll_id', $poll_id)); - $poll_form->addElement(new XoopsFormButton('', 'poll_submit', _MD_POLL_RESTART, 'submit')); - - echo '

    ' . _MD_POLL_POLLCONF . "

    \n"; - $poll_form->display(); - - break; - - case 'restart_ok': - // check security token - if (!$GLOBALS['xoopsSecurity']->check()) { - redirect_header($_SERVER['PHP_SELF'], 2, implode('
    ', $GLOBALS['xoopsSecurity']->getErrors())); - } - - $poll_obj = $xpPollHandler->get($poll_id); - $default_poll_duration = XoopspollConstants::DEFAULT_POLL_DURATION; - $poll_mailed = XoopspollConstants::POLL_MAILED; - $poll_not_mailed = XoopspollConstants::POLL_NOT_MAILED; - - $end_time = empty($_POST['end_time']) ? 0 : (int)$_POST['end_time']; - if (!empty($end_time)) { - $timezone = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; - // $poll_obj->setVar("end_time", userTimeToServerTime(strtotime($end_time), $timezone)); - //Hack by irmtfan - $poll_obj->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); - } else { - $poll_obj->setVar('end_time', time() + $default_poll_duration); - } - if (!empty($_POST['notify']) && ($end_time > time())) { - // if notify, set mail status to "not mailed" - $poll_obj->setVar('mail_status', $poll_not_mailed); - } else { - // if not notify, set mail status to already "mailed" - $poll_obj->setVar('mail_status', $poll_mailed); - } - - if (!$xpPollHandler->insert($poll_obj)) { // update the poll - xoops_error($poll_obj->getHtmlErrors()); - exit(); - } - if (!empty($_POST['reset'])) { // reset all vote/voter counters - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - $xpLogHandler->deleteByPollId($poll_id); - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $xpOptHandler->resetCountByPollId($poll_id); - $xpPollHandler->updateCount($poll_obj); - } - - // clear the topic votes - include_once $GLOBALS['xoops']->path('class/template.php'); - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); - xoops_template_clear_module_cache($xoopspoll->getVar('mid')); - redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_DBUPDATED); - break; - - case 'log': - redirect_header($GLOBALS['xoops']->url("modules/xoopspoll/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_LOG_XOOPSPOLL_ADMIN_REDIRECT); - break; -} - -include $GLOBALS['xoops']->path('footer.php'); diff --git a/extras/newbb_4x/trunk_4_00/templates/index.html b/extras/newbb_4x/trunk_4_00/templates/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_4x/trunk_4_00/templates/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_4x/trunk_4_00/templates/newbb_poll_results.html b/extras/newbb_4x/trunk_4_00/templates/newbb_poll_results.html deleted file mode 100644 index d8b9f22..0000000 --- a/extras/newbb_4x/trunk_4_00/templates/newbb_poll_results.html +++ /dev/null @@ -1,5 +0,0 @@ -
    -
    - <{$topic_pollresult}> -
    -
    \ No newline at end of file diff --git a/extras/newbb_4x/trunk_4_00/templates/newbb_poll_results.tpl b/extras/newbb_4x/trunk_4_00/templates/newbb_poll_results.tpl deleted file mode 100644 index 7f78cf7..0000000 --- a/extras/newbb_4x/trunk_4_00/templates/newbb_poll_results.tpl +++ /dev/null @@ -1,5 +0,0 @@ -
    -
    - <{$topic_pollresult}> -
    -
    diff --git a/extras/newbb_4x/trunk_4_00/templates/newbb_poll_view.html b/extras/newbb_4x/trunk_4_00/templates/newbb_poll_view.html deleted file mode 100644 index 4172df3..0000000 --- a/extras/newbb_4x/trunk_4_00/templates/newbb_poll_view.html +++ /dev/null @@ -1 +0,0 @@ -<{$topic_pollform}> \ No newline at end of file diff --git a/extras/newbb_4x/trunk_4_00/templates/newbb_poll_view.tpl b/extras/newbb_4x/trunk_4_00/templates/newbb_poll_view.tpl deleted file mode 100644 index 4172df3..0000000 --- a/extras/newbb_4x/trunk_4_00/templates/newbb_poll_view.tpl +++ /dev/null @@ -1 +0,0 @@ -<{$topic_pollform}> \ No newline at end of file diff --git a/extras/newbb_4x/trunk_4_00/topicmanager.php b/extras/newbb_4x/trunk_4_00/topicmanager.php deleted file mode 100644 index 965e0c3..0000000 --- a/extras/newbb_4x/trunk_4_00/topicmanager.php +++ /dev/null @@ -1,224 +0,0 @@ - - */ -include __DIR__ . '/header.php'; - -if (isset($_POST['submit'])) { - foreach (['forum', 'topic_id', 'newforum', 'newtopic'] as $getint) { - ${$getint} = (int)(@$_POST[$getint]); - } -} else { - foreach (['forum', 'topic_id'] as $getint) { - ${$getint} = (int)(@$_GET[$getint]); - } -} - -if (!$topic_id) { - $redirect = empty($forum_id) ? 'index.php' : "viewforum.php?forum={$forum}"; - redirect_header($redirect, 2, _MD_ERRORTOPIC); -} - -/** @var NewbbTopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); -$forum = $topicHandler->get($topic_id, 'forum_id'); -$forum_new = !empty($newtopic) ? $topicHandler->get($newtopic, 'forum_id') : 0; - -/** @var NewbbForumHandler $forumHandler */ -$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); -if (!$forumHandler->getPermission($forum, 'moderate') - || (!empty($forum_new) - && !$forumHandler->getPermission($forum_new, 'reply'))// The forum for the topic to be merged to - || (!empty($newforum) && !$forumHandler->getPermission($newforum, 'post')) // The forum to be moved to -) { - redirect_header("viewtopic.php?forum={$forum}&topic_id={$topic_id}", 2, _NOPERM); -} - -if ($xoopsModuleConfig['wol_enabled']) { - $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); - $onlineHandler->init($forum); -} - -$action_array = ['merge', 'delete', 'move', 'lock', 'unlock', 'sticky', 'unsticky', 'digest', 'undigest']; -foreach ($action_array as $_action) { - $action[$_action] = [ - 'name' => $_action, - 'desc' => constant(strtoupper("_MD_DESC_{$_action}")), - 'submit' => constant(strtoupper("_MD_{$_action}")), - 'sql' => "topic_{$_action}=1", - 'msg' => constant(strtoupper("_MD_TOPIC{$_action}")) - ]; -} -$action['lock']['sql'] = 'topic_status = 1'; -$action['unlock']['sql'] = 'topic_status = 0'; -$action['unsticky']['sql'] = 'topic_sticky = 0'; -$action['undigest']['sql'] = 'topic_digest = 0'; -$action['digest']['sql'] = 'topic_digest = 1, digest_time = ' . time(); - -// Disable cache -$xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; -include XOOPS_ROOT_PATH . '/header.php'; - -if (isset($_POST['submit'])) { - $mode = $_POST['mode']; - if ('delete' === $mode) { - $topic_obj = $topicHandler->get($topic_id); - $topicHandler->delete($topic_obj); - $forumHandler->synchronization($forum); - - $topic_obj->loadFilters('delete'); - echo $action[$mode]['msg'] . "

    " . _MD_RETURNTOTHEFORUM . "

    " . _MD_RETURNFORUMINDEX . '

    '; - } elseif ('merge' === $mode) { - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); - - $topic_obj = $topicHandler->get($topic_id); - $newtopic_obj = $topicHandler->get($newtopic); - /* return false if destination topic is newer or not existing */ - if ($newtopic > $topic_id || !is_object($newtopic_obj)) { - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERROR); - } - - $criteria_topic = new Criteria('topic_id', $topic_id); - $criteria = new CriteriaCompo($criteria_topic); - $criteria->add(new Criteria('pid', 0)); - $postHandler->updateAll('pid', $topicHandler->getTopPostId($newtopic), $criteria, true); - $postHandler->updateAll('topic_id', $newtopic, $criteria_topic, true); - - $topic_views = $topic_obj->getVar('topic_views') + $newtopic_obj->getVar('topic_views'); - $criteria_newtopic = new Criteria('topic_id', $newtopic); - $topicHandler->updateAll('topic_views', $topic_views, $criteria_newtopic, true); - - $topicHandler->synchronization($newtopic); - - $poll_id = $topicHandler->get($topic_id, 'poll_id'); - - if ($poll_id > 0) { - /** @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $pollModule = $moduleHandler->getByDirname('xoopspoll'); - if (($pollModule instanceof XoopsModule) && $pollModule->isactive()) { - $xpPollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); - $poll = $xpPollHandler->get($poll_id); - if (false !== $xpPollHandler->delete($poll)) { - $xpOptHandler = xoops_getModuleHandler('option', 'xoopspoll'); - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); - $xpOptHandler->deleteByPollId($poll_id); - $xpLogHandler->deleteByPollId($poll_id); - xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); - } - } - } - - $sql = sprintf('DELETE FROM %s WHERE topic_id = %u', $xoopsDB->prefix('bb_topics'), $topic_id); - $result = $xoopsDB->queryF($sql); - - $sql = sprintf('DELETE FROM %s WHERE topic_id = %u', $xoopsDB->prefix('bb_votedata'), $topic_id); - $result = $xoopsDB->queryF($sql); - - $sql = sprintf('UPDATE %s SET forum_topics = forum_topics-1 WHERE forum_id = %u', $xoopsDB->prefix('bb_forums'), $forum); - $result = $xoopsDB->queryF($sql); - - $topic_obj->loadFilters('delete'); - $newtopic_obj->loadFilters('update'); - - echo $action[$mode]['msg'] . "

    " . _MD_VIEWTHETOPIC . '

    ' . "

    " . _MD_RETURNTOTHEFORUM . '

    ' . "

    " - . _MD_RETURNFORUMINDEX . '

    '; - } elseif ('move' === $mode) { - if ($newforum > 0) { - $topic_obj = $topicHandler->get($topic_id); - $topic_obj->loadFilters('update'); - $topic_obj->setVar('forum_id', $newforum, true); - $topicHandler->insert($topic_obj, true); - $topic_obj->loadFilters('update'); - - $sql = sprintf('UPDATE %s SET forum_id = %u WHERE topic_id = %u', $xoopsDB->prefix('bb_posts'), $newforum, $topic_id); - if (!$r = $xoopsDB->query($sql)) { - return false; - } - $forumHandler->synchronization($newforum); - $forumHandler->synchronization($forum); - echo $action[$mode]['msg'] . "

    " . _MD_GOTONEWFORUM . "

    " . _MD_RETURNFORUMINDEX . '

    '; - } else { - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_ERRORFORUM); - } - } else { - $sql = sprintf('UPDATE %s SET ' . $action[$mode]['sql'] . ' WHERE topic_id = %u', $xoopsDB->prefix('bb_topics'), $topic_id); - if (!$r = $xoopsDB->query($sql)) { - redirect_header("viewtopic.php?forum={$forum}&topic_id={$topic_id}&order={$order}&viewmode={$viewmode}", 2, _MD_ERROR_BACK . '
    sql:' . $sql); - } - if ('digest' === $mode && $xoopsDB->getAffectedRows()) { - $topic_obj = $topicHandler->get($topic_id); - $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats'); - $statsHandler->update($topic_obj->getVar('forum_id'), 'digest'); - $userstatsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Userstats'); - if ($user_stat = $userstatsHandler->get($topic_obj->getVar('topic_poster'))) { - $user_stat->setVar('user_digests', $user_stat->getVar('user_digests') + 1); - $userstatsHandler->insert($user_stat); - } - } - echo $action[$mode]['msg'] . "

    " . _MD_VIEWTHETOPIC . "

    " . _MD_RETURNFORUMINDEX . '

    '; - } -} else { // No submit - $mode = $_GET['mode']; - echo "
    "; - echo ""; - echo "
    "; - echo ""; - echo ""; - echo "'; - - if ('move' === $mode) { - echo ''; - } - if ('merge' === $mode) { - echo ''; - } - echo '
    " . $action[$mode]['desc'] . '
    ' . _MD_MOVETOPICTO . ''; - $box = '
    ' . _MD_MERGETOPICTO . ''; - echo _MD_TOPIC . " ID-{$topic_id} -> ID: "; - echo '
    '; - echo ""; - echo ""; - echo ""; - echo ""; - echo '
    '; -} -include XOOPS_ROOT_PATH . '/footer.php'; diff --git a/extras/newbb_4x/trunk_4_00/viewtopic.php b/extras/newbb_4x/trunk_4_00/viewtopic.php deleted file mode 100644 index 83a932f..0000000 --- a/extras/newbb_4x/trunk_4_00/viewtopic.php +++ /dev/null @@ -1,688 +0,0 @@ - - */ -include __DIR__ . '/header.php'; -require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.read.php'; -require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.render.php'; - -/* - * Build the page query - */ -$query_vars = ['post_id', 'topic_id', 'status', 'order', 'start', 'move', 'mode', 'viewmode']; -$query_array = []; -foreach ($query_vars as $var) { - if (empty($_GET[$var])) { - continue; - } - $query_array[$var] = "{$var}={$_GET[$var]}"; -} -$page_query = htmlspecialchars(implode('&', $query_array), ENT_QUOTES | ENT_HTML5); -unset($query_array); - -$topic_id = isset($_GET['topic_id']) ? (int)$_GET['topic_id'] : 0; -$post_id = !empty($_GET['post_id']) ? (int)$_GET['post_id'] : 0; -$forum_id = !empty($_GET['forum']) ? (int)$_GET['forum'] : 0; -$move = isset($_GET['move']) ? strtolower($_GET['move']) : ''; -$start = !empty($_GET['start']) ? (int)$_GET['start'] : 0; -$status = (!empty($_GET['status']) - && in_array($_GET['status'], ['active', 'pending', 'deleted'])) ? $_GET['status'] : ''; -$mode = !empty($_GET['mode']) ? (int)$_GET['mode'] : (!empty($status) ? 2 : 0); - -if (!$topic_id && !$post_id) { - $redirect = empty($forum_id) ? 'index.php' : "viewforum.php?forum={$forum_id}"; - redirect_header($redirect, 2, _MD_ERRORTOPIC); -} - -/** @var NewbbTopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); -if (!empty($post_id)) { - $topic_obj = $topicHandler->getByPost($post_id); -} elseif (!empty($move)) { - $topic_obj = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id); - $topic_id = $topic_obj->getVar('topic_id'); -} else { - $topic_obj = $topicHandler->get($topic_id); -} -if (!is_object($topic_obj) || !$topic_id = $topic_obj->getVar('topic_id')) { - $redirect = empty($forum_id) ? 'index.php' : "viewforum.php?forum={$forum_id}"; - redirect_header($redirect, 2, _MD_ERRORTOPIC); -} -$forum_id = $topic_obj->getVar('forum_id'); -/** @var NewbbForumHandler $forumHandler */ -$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); -$forum_obj = $forumHandler->get($forum_id); - -$isadmin = newbb_isAdmin($forum_obj); - -if (!$isadmin && $topic_obj->getVar('approved') < 0) { - redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NORIGHTTOVIEW); -} -if (!$forumHandler->getPermission($forum_obj)) { - redirect_header('index.php', 2, _MD_NORIGHTTOACCESS); -} -/* Only admin has access to admin mode */ -if (!$isadmin) { - $status = ''; - $mode = 0; -} -if ($mode) { - $_GET['viewmode'] = 'flat'; -} - -if (!$topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'view')) { - redirect_header("viewforum.php?forum={$forum_id}", 2, _MD_NORIGHTTOVIEW); -} - -$karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma'); -$user_karma = $karmaHandler->getUserKarma(); - -$valid_modes = $xoopsModuleConfig['valid_viewmodes']; -$viewmode_cookie = newbb_getcookie('V'); -if (isset($_GET['viewmode']) && in_array($_GET['viewmode'], $valid_modes)) { - newbb_setcookie('V', $_GET['viewmode'], $forumCookie['expire']); -} -$viewmode = $_GET['viewmode'] ?? (!empty($viewmode_cookie) ? $viewmode_cookie : @$valid_modes[$xoopsModuleConfig['view_mode'] - 1]); -$viewmode = @in_array($viewmode, $valid_modes) ? $viewmode : $valid_modes[0]; -$order = (isset($_GET['order']) - && in_array(strtoupper($_GET['order']), ['DESC', 'ASC'])) ? $_GET['order'] : 'ASC'; - -$total_posts = $topicHandler->getPostCount($topic_obj, $status); - -$xoopsLogger->startTime('XOOPS output module - topic - post'); - -if ('thread' === $viewmode) { - $GLOBALS['xoopsOption']['template_main'] = 'newbb_viewtopic_thread.tpl'; - if (!empty($xoopsModuleConfig['posts_for_thread']) && $total_posts > $xoopsModuleConfig['posts_for_thread']) { - redirect_header("viewtopic.php?topic_id={$topic_id}&viewmode=flat", 2, _MD_EXCEEDTHREADVIEW); - } - $postsArray = $topicHandler->getAllPosts($topic_obj, $order, $total_posts, $start, 0, $status); -} else { - $GLOBALS['xoopsOption']['template_main'] = 'newbb_viewtopic_flat.tpl'; - $postsArray = $topicHandler->getAllPosts($topic_obj, $order, $xoopsModuleConfig['posts_per_page'], $start, $post_id, $status); -} - -$xoopsLogger->stopTime('XOOPS output module - topic - post'); - -$topic_obj->incrementCounter(); -newbb_setRead('topic', $topic_id, $topic_obj->getVar('topic_last_post_id')); - -if (!empty($xoopsModuleConfig['rss_enable'])) { - $xoops_module_header .= ''; -} -$xoops_pagetitle = $topic_obj->getVar('topic_title') . ' [' . $xoopsModule->getVar('name') . ' - ' . $forum_obj->getVar('forum_name') . ']'; - -$xoopsOption['xoops_pagetitle'] = $xoops_pagetitle; -$xoopsOption['xoops_module_header'] = $xoops_module_header; -include XOOPS_ROOT_PATH . '/header.php'; - -$xoopsLogger->startTime('XOOPS output module - topic'); - -$xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle); -$xoopsTpl->assign('xoops_module_header', $xoops_module_header); - -if ($xoopsModuleConfig['wol_enabled']) { - $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); - $onlineHandler->init($forum_obj, $topic_obj); - $xoopsTpl->assign('online', $onlineHandler->showOnline()); -} - -$xoopsTpl->assign('parentforum', $forumHandler->getParents($forum_obj)); - -$xoopsTpl->assign( - [ - 'topic_title' => '' . $topic_obj->getFullTitle() . '', - 'forum_name' => $forum_obj->getVar('forum_name'), - 'lang_nexttopic' => _MD_NEXTTOPIC, - 'lang_prevtopic' => _MD_PREVTOPIC - ] -); - -$categoryHandler = xoops_getModuleHandler('category'); -$category_obj = $categoryHandler->get($forum_obj->getVar('cat_id'), ['cat_title']); -$xoopsTpl->assign('category', ['id' => $forum_obj->getVar('cat_id'), 'title' => $category_obj->getVar('cat_title')]); - -$xoopsTpl->assign('topic_id', $topic_id); -$xoopsTpl->assign('forum_id', $forum_id); - -$order_current = ('DESC' === $order) ? 'DESC' : 'ASC'; -$xoopsTpl->assign('order_current', $order_current); - -$t_new = newbb_displayImage('t_new', _MD_POSTNEW); -$t_reply = newbb_displayImage('t_reply', _MD_REPLY); - -if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'post')) { - $xoopsTpl->assign('forum_post_or_register', "{$t_new}"); -} elseif (!empty($GLOBALS['xoopsModuleConfig']['show_reg'])) { - if ($topic_obj->getVar('topic_status')) { - $xoopsTpl->assign('forum_post_or_register', _MD_TOPICLOCKED); - } elseif (!is_object($xoopsUser)) { - $xoopsTpl->assign('forum_post_or_register', '' . _MD_REGTOPOST . ''); - } -} else { - $xoopsTpl->assign('forum_post_or_register', ''); -} -if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'reply')) { - $xoopsTpl->assign('forum_reply', "{$t_reply}"); -} - -$poster_array = []; -$require_reply = false; -foreach ($postsArray as $eachpost) { - if ($eachpost->getVar('uid') > 0) { - $poster_array[$eachpost->getVar('uid')] = 1; - } - if ($eachpost->getVar('require_reply') > 0) { - $require_reply = true; - } -} -$userid_array = []; -$online = []; -if (count($poster_array) > 0) { - $memberHandler = xoops_getHandler('member'); - $userid_array = array_keys($poster_array); - //$user_criteria = "(" . implode(",", $userid_array) . ")"; - $users = $memberHandler->getUsers(new Criteria('uid', '(' . implode(',', $userid_array) . ')', 'IN'), true); -} else { - $users = []; -} - -$xoopsLogger->startTime('XOOPS output module - topic - user'); - -$xoopsLogger->startTime('XOOPS output module - topic - user - user'); -$viewtopic_users = []; -if (count($userid_array) > 0) { - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/user.php'; - $userHandler = new \NewbbUserHandler($xoopsModuleConfig['groupbar_enabled'], $xoopsModuleConfig['wol_enabled']); - $userHandler->users = $users; - $userHandler->online = $online; - $viewtopic_users = $userHandler->getUsers(); -} -unset($users); -$xoopsLogger->stopTime('XOOPS output module - topic - user - user'); - -$xoopsLogger->stopTime('XOOPS output module - topic - user'); - -if ($xoopsModuleConfig['allow_require_reply'] && $require_reply) { - if (!empty($xoopsModuleConfig['cache_enabled'])) { - $viewtopic_posters = newbb_getsession('t' . $topic_id, true); - if (!is_array($viewtopic_posters) || 0 === count($viewtopic_posters)) { - $viewtopic_posters = $topicHandler->getAllPosters($topic_obj); - newbb_setsession('t' . $topic_id, $viewtopic_posters); - } - } else { - $viewtopic_posters = $topicHandler->getAllPosters($topic_obj); - } -} else { - $viewtopic_posters = []; -} - -$xoopsLogger->startTime('XOOPS output module - topic - assign'); - -if ('thread' === $viewmode) { - if (!empty($post_id)) { - $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post'); - $currentPost = $postHandler->get($post_id); - - if (!$isadmin && $currentPost->getVar('approved') < 0) { - redirect_header('viewtopic.php?topic_id=' . $topic_id, 2, _MD_NORIGHTTOVIEW); - } - - $top_pid = $topicHandler->getTopPostId($topic_id); - } else { - $currentPost = $topicHandler->getTopPost($topic_id); - $top_pid = $currentPost->getVar('post_id'); - } - - $xoopsTpl->append('topic_posts', $currentPost->showPost($isadmin)); - - $postArray = $topicHandler->getPostTree($postsArray); - if (count($postArray) > 0) { - foreach ($postArray as $treeItem) { - $topicHandler->showTreeItem($topic_obj, $treeItem); - if ($treeItem['post_id'] === $post_id) { - $treeItem['subject'] = '' . $treeItem['subject'] . ''; - } - $xoopsTpl->append('topic_trees', [ - 'post_id' => $treeItem['post_id'], - 'post_time' => $treeItem['post_time'], - 'post_image' => $treeItem['icon'], - 'post_title' => $treeItem['subject'], - 'post_prefix' => $treeItem['prefix'], - 'poster' => $treeItem['poster'] - ] - ); - } - unset($postArray); - } -} else { - foreach ($postsArray as $eachpost) { - $xoopsTpl->append('topic_posts', $eachpost->showPost($isadmin)); - } - - if ($total_posts > $xoopsModuleConfig['posts_per_page']) { - include XOOPS_ROOT_PATH . '/class/pagenav.php'; - $nav = new XoopsPageNav($total_posts, $xoopsModuleConfig['posts_per_page'], $start, 'start', 'topic_id=' . $topic_id . '&viewmode=' . $viewmode . '&order=' . $order . '&status=' . $status . '&mode=' . $mode); - $xoopsTpl->assign('forum_page_nav', $nav->renderNav(4)); - } else { - $xoopsTpl->assign('forum_page_nav', ''); - } -} -unset($postsArray); -$xoopsLogger->stopTime('XOOPS output module - topic - assign'); - -$xoopsTpl->assign('topic_print_link', "print.php?form=1&{$page_query}"); - -$admin_actions = []; - -$ad_merge = ''; -$ad_move = ''; -$ad_delete = ''; -$ad_lock = ''; -$ad_unlock = ''; -$ad_sticky = ''; -$ad_unsticky = ''; -$ad_digest = ''; -$ad_undigest = ''; - -$link_string = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=%s&topic_id=' . $topic_id; -$admin_actions['merge'] = [ - 'link' => sprintf($link_string, 'merge'), - 'name' => _MD_MERGETOPIC, - 'image' => $ad_merge -]; -$admin_actions['move'] = [ - 'link' => sprintf($link_string, 'move'), - 'name' => _MD_MOVETOPIC, - 'image' => $ad_move -]; -$admin_actions['delete'] = [ - 'link' => sprintf($link_string, 'delete'), - 'name' => _MD_DELETETOPIC, - 'image' => $ad_delete -]; -if (!$topic_obj->getVar('topic_status')) { - $admin_actions['lock'] = [ - 'link' => sprintf($link_string, 'lock'), - 'image' => $ad_lock, - 'name' => _MD_LOCKTOPIC - ]; -} else { - $admin_actions['unlock'] = [ - 'link' => sprintf($link_string, 'unlock'), - 'image' => $ad_unlock, - 'name' => _MD_UNLOCKTOPIC - ]; -} -if (!$topic_obj->getVar('topic_sticky')) { - $admin_actions['sticky'] = [ - 'link' => sprintf($link_string, 'sticky'), - 'image' => $ad_sticky, - 'name' => _MD_STICKYTOPIC - ]; -} else { - $admin_actions['unsticky'] = [ - 'link' => sprintf($link_string, 'unsticky'), - 'image' => $ad_unsticky, - 'name' => _MD_UNSTICKYTOPIC - ]; -} -if (!$topic_obj->getVar('topic_digest')) { - $admin_actions['digest'] = [ - 'link' => sprintf($link_string, 'digest'), - 'image' => $ad_digest, - 'name' => _MD_DIGESTTOPIC - ]; -} else { - $admin_actions['undigest'] = [ - 'link' => sprintf($link_string, 'undigest'), - 'image' => $ad_undigest, - 'name' => _MD_UNDIGESTTOPIC - ]; -} -$xoopsTpl->assign_by_ref('admin_actions', $admin_actions); - -$xoopsTpl->assign('viewer_level', $isadmin ? 2 : is_object($xoopsUser)); - -if ($xoopsModuleConfig['show_permissiontable']) { - $permissionHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); - $permission_table = $permissionHandler->getPermissionTable($forum_obj, $topic_obj->getVar('topic_status'), $isadmin); - $xoopsTpl->assign_by_ref('permission_table', $permission_table); -} - -/////////////////////////////// -// show Poll -/** @var XoopsModuleHandler $moduleHandler */ -$moduleHandler = xoops_getHandler('module'); -$xoopspoll = $moduleHandler->getByDirname('xoopspoll'); -if (($xoopspoll instanceof XoopsModule) && $xoopspoll->isactive()) { - if (($topic_obj->getVar('topic_haspoll') - && $topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'vote')) - || $topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'addpoll') - ) { - xoops_load('renderer', 'xoopspoll'); - xoops_loadLanguage('main', 'xoopspoll'); - } - - if ($topic_obj->getVar('topic_haspoll') && (0 !== $topic_obj->getVar('poll_id')) - // double check to make sure it's a non-zero poll - && $topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'vote') - ) { - $GLOBALS['xoopsTpl']->assign('topic_poll', 1); - $GLOBALS['xoopsTpl']->assign('pollmodules', $pollmodules); - $uid = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; - - $xpollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); - $poll_obj = $xpollHandler->get($topic_obj->getVar('poll_id')); - if (!empty($poll_obj) && $poll_obj instanceof \XoopspollPoll) { - - /* check to see if user has rights to view the results */ - $vis_return = $poll_obj->isResultVisible(); - $isVisible = (true === $vis_return) ? true : false; - $visibleMsg = $isVisible ? '' : $vis_return; - - /* setup the module config handler */ - $configHandler = xoops_getHandler('config'); - $xp_config = $configHandler->getConfigsByCat(0, $xoopspoll->getVar('mid')); - - $GLOBALS['xoopsTpl']->assign( - [ - 'is_visible' => $isVisible, - 'visible_message' => $visibleMsg, - 'disp_votes' => $xp_config['disp_vote_nums'], - 'lang_vote' => _MD_XOOPSPOLL_VOTE, - 'lang_results' => _MD_XOOPSPOLL_RESULTS, - 'back_link' => '' - ] - ); - $renderer = new \XoopspollRenderer($poll_obj); - //check to see if user has voted, show form if not, otherwise get results for form - $logHandler = xoops_getModuleHandler('log', 'xoopspoll'); - if ($poll_obj->isAllowedToVote() - && (!$logHandler->hasVoted($poll_obj->getVar('poll_id'), xoops_getenv('REMOTE_ADDR'), $uid)) - ) { - $myTpl = new XoopsTpl(); - $renderer->assignForm($myTpl); - $myTpl->assign('action', $GLOBALS['xoops']->url("modules/newbb/votepolls.php?topic_id={$topic_id}&poll_id={$poll_id}")); - $topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/xoopspoll/templates/xoopspoll_view.tpl')); - $GLOBALS['xoopsTpl']->assign('topic_pollform', $topic_pollform); - } else { - $GLOBALS['xoopsTpl']->assign('can_vote', false); - $GLOBALS['xoopsTpl']->assign('topic_pollresult', $renderer->renderResults()); - } - } - } - - if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'addpoll')) { - if (!$topic_obj->getVar('topic_haspoll')) { - if (($xoopsUser instanceof XoopsUser) && $xoopsUser->getVar('uid') === $topic_obj->getVar('topic_poster')) { - $t_poll = newbb_displayImage('t_poll', _MD_ADDPOLL); - $xoopsTpl->assign('forum_addpoll', "getVar('dirname', 'n') . "/polls.php?op=add&topic_id={$topic_id}\">{$t_poll}"); - } - } elseif ($isadmin - || (is_object($poll) && ($xoopsUser instanceof XoopsUser) - && $xoopsUser->getVar('uid') === $poll_obj->getVar('user_id')) - ) { - $poll_edit = ''; - $poll_delete = ''; - $poll_restart = ''; - - $adminpoll_actions = []; - $adminpoll_actions['editpoll'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=edit&poll_id=' . $topic_obj->getVar('poll_id') . '&topic_id=' . $topic_id, - 'image' => $poll_edit, - 'name' => _MD_EDITPOLL - ]; - $adminpoll_actions['deletepoll'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=delete&poll_id=' . $topic_obj->getVar('poll_id') . '&topic_id=' . $topic_id, - 'image' => $poll_delete, - 'name' => _MD_DELETEPOLL - ]; - $adminpoll_actions['restartpoll'] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=restart&poll_id=' . $topic_obj->getVar('poll_id') . '&topic_id=' . $topic_id . '&forum=' . $forum_id, - 'image' => $poll_restart, - 'name' => _MD_RESTARTPOLL - ]; - - $xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions); - } - } - if (isset($poll_obj)) { - unset($poll_obj); - } -} -$xoopsTpl->assign('up', newbb_displayImage('up', _MD_TOP)); -$xoopsTpl->assign('rating_enable', $xoopsModuleConfig['rating_enabled']); -$xoopsTpl->assign('groupbar_enable', $xoopsModuleConfig['groupbar_enabled']); -$xoopsTpl->assign('anonymous_prefix', $xoopsModuleConfig['anonymous_prefix']); - -$xoopsTpl->assign('previous', newbb_displayImage('previous')); -$xoopsTpl->assign('next', newbb_displayImage('next')); -$xoopsTpl->assign('down', newbb_displayImage('down')); -$xoopsTpl->assign('post_content', newbb_displayImage('post')); - -if (!empty($xoopsModuleConfig['rating_enabled'])) { - $xoopsTpl->assign('votes', $topic_obj->getVar('votes')); - $rating = number_format($topic_obj->getVar('rating') / 2, 0); - if ($rating < 1) { - $rating_img = newbb_displayImage('blank'); - } else { - $rating_img = newbb_displayImage('rate' . $rating); - } - $xoopsTpl->assign('rating_img', $rating_img); - $xoopsTpl->assign('rate1', newbb_displayImage('rate1', _MD_RATE1)); - $xoopsTpl->assign('rate2', newbb_displayImage('rate2', _MD_RATE2)); - $xoopsTpl->assign('rate3', newbb_displayImage('rate3', _MD_RATE3)); - $xoopsTpl->assign('rate4', newbb_displayImage('rate4', _MD_RATE4)); - $xoopsTpl->assign('rate5', newbb_displayImage('rate5', _MD_RATE5)); -} - -// create jump box -if (!empty($xoopsModuleConfig['show_jump'])) { - require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.forum.php'; - $xoopsTpl->assign('forum_jumpbox', newbb_make_jumpbox($forum_id)); -} -$xoopsTpl->assign( - [ - 'lang_forum_index' => sprintf(_MD_FORUMINDEX, htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)), - 'lang_from' => _MD_FROM, - 'lang_joined' => _MD_JOINED, - 'lang_posts' => _MD_POSTS, - 'lang_poster' => _MD_POSTER, - 'lang_thread' => _MD_THREAD, - 'lang_edit' => _EDIT, - 'lang_delete' => _DELETE, - 'lang_reply' => _REPLY, - 'lang_postedon' => _MD_POSTEDON, - 'lang_groups' => _MD_GROUPS - ] -); - -$viewmode_options = []; -if ('thread' === $viewmode) { - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=flat&topic_id=' . $topic_id, - 'title' => _FLAT - ]; - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=compact&topic_id=' . $topic_id, - 'title' => _MD_COMPACT - ]; -} elseif ('compact' === $viewmode) { - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=thread&topic_id=' . $topic_id, - 'title' => _THREADED - ]; - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=flat&order={$order_current}&topic_id=' . $topic_id, - 'title' => _FLAT - ]; - if ('DESC' === $order) { - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=compact&order=ASC&topic_id=' . $topic_id, - 'title' => _OLDESTFIRST - ]; - } else { - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=compact&order=DESC&topic_id=' . $topic_id, - 'title' => _NEWESTFIRST - ]; - } -} else { - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=thread&topic_id=' . $topic_id, - 'title' => _THREADED - ]; - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=compact&order={$order_current}&topic_id=' . $topic_id, - 'title' => _MD_COMPACT - ]; - if ('DESC' === $order) { - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=flat&order=ASC&status={$status}&topic_id=' . $topic_id, - 'title' => _OLDESTFIRST - ]; - } else { - $viewmode_options[] = [ - 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?viewmode=flat&order=DESC&status={$status}&topic_id=' . $topic_id, - 'title' => _NEWESTFIRST - ]; - } -} -switch ($status) { - case 'active': - $current_status = '[' . _MD_TYPE_ADMIN . ']'; - break; - case 'pending': - $current_status = '[' . _MD_TYPE_PENDING . ']'; - break; - case 'deleted': - $current_status = '[' . _MD_TYPE_DELETED . ']'; - break; - default: - $current_status = ''; - break; -} -$xoopsTpl->assign('topicstatus', $current_status); - -$xoopsTpl->assign('mode', $mode); -$xoopsTpl->assign('status', $status); -$xoopsTpl->assign('viewmode_compact', ('compact' === $viewmode) ? 1 : 0); -$xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options); -unset($viewmode_options); -$xoopsTpl->assign('menumode', $menumode); -$xoopsTpl->assign('menumode_other', $menumode_other); - -$xoopsLogger->startTime('XOOPS output module - topic - quickreply'); - -if (!empty($xoopsModuleConfig['quickreply_enabled']) - && $topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'reply') -) { - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelement.php'; - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formhidden.php'; - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formhiddentoken.php'; - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formbutton.php'; - require_once XOOPS_ROOT_PATH . '/class/xoopsform/themeform.php'; - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formtextarea.php'; - if (!@include_once XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php') { - require_once XOOPS_ROOT_PATH . '/Frameworks/compat/class/xoopsform/formeditor.php'; - } - - $xoopsLogger->startTime('XOOPS output module - topic - quickreply - form'); - $forum_form = new XoopsThemeForm(_MD_POSTREPLY, 'quick_reply', 'post.php', 'post', true); - - if (!is_object($xoopsUser)) { - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formpassword.php'; - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formcheckbox.php'; - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formtext.php'; - require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelementtray.php'; - require_once XOOPS_ROOT_PATH . '/Frameworks/captcha/formcaptcha.php'; - $configHandler = xoops_getHandler('config'); - $user_tray = new XoopsFormElementTray(_MD_ACCOUNT); - $user_tray->addElement(new XoopsFormText(_MD_NAME, 'uname', 26, 255)); - $user_tray->addElement(new XoopsFormPassword(_MD_PASSWORD, 'pass', 10, 32)); - $login_checkbox = new XoopsFormCheckBox('', 'login', 1); - $login_checkbox->addOption(1, _MD_LOGIN); - $user_tray->addElement($login_checkbox); - $forum_form->addElement($user_tray); - $captcha = new XoopsFormCaptcha('', 'topic_{$topic_id}_{$start}'); - $captcha->setConfig('mode', 'text'); - $forum_form->addElement($captcha); - } - - $quickform = 'textarea'; - $editor_configs = []; - $editor_configs['caption'] = _MD_MESSAGEC; - $editor_configs['name'] = 'message'; - $editor_configs['rows'] = 10; - $editor_configs['cols'] = 60; - $forum_form->addElement(new XoopsFormEditor(_MD_MESSAGEC, $quickform, $editor_configs, true), true); - - $forum_form->addElement(new XoopsFormHidden('dohtml', 0)); - $forum_form->addElement(new XoopsFormHidden('dosmiley', 1)); - $forum_form->addElement(new XoopsFormHidden('doxcode', 1)); - $forum_form->addElement(new XoopsFormHidden('dobr', 1)); - $forum_form->addElement(new XoopsFormHidden('attachsig', 1)); - - $forum_form->addElement(new XoopsFormHidden('isreply', 1)); - - $forum_form->addElement(new XoopsFormHidden('subject', _MD_RE . ': ' . $topic_obj->getVar('topic_title', 'e'))); - $forum_form->addElement(new XoopsFormHidden('pid', empty($post_id) ? $topicHandler->getTopPostId($topic_id) : $post_id)); - $forum_form->addElement(new XoopsFormHidden('topic_id', $topic_id)); - $forum_form->addElement(new XoopsFormHidden('forum', $forum_id)); - $forum_form->addElement(new XoopsFormHidden('viewmode', $viewmode)); - $forum_form->addElement(new XoopsFormHidden('order', $order)); - $forum_form->addElement(new XoopsFormHidden('start', $start)); - - $forum_form->addElement(new XoopsFormHidden('notify', -1)); - $forum_form->addElement(new XoopsFormHidden('contents_submit', 1)); - - $submit_button = new XoopsFormButton('', 'quick_submit', _SUBMIT, 'submit'); - $submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value == \'RE\' || document.forms.quick_reply.message.value == \'\') { alert(\'' . _MD_QUICKREPLY_EMPTY . '\'); return false;} else { return true;}"'); - $forum_form->addElement($submit_button); - - $toggles = newbb_getcookie('G', true); - $display = in_array('qr', $toggles) ? 'none;' : 'block;'; - $xoopsTpl->assign('quickreply', [ - 'show' => 1, - 'display' => $display, - 'icon' => newbb_displayImage('t_qr'), - 'form' => $forum_form->render() - ] - ); - unset($forum_form); - $xoopsLogger->stopTime('XOOPS output module - topic - quickreply - form'); -} else { - $xoopsTpl->assign('quickreply', ['show' => 0]); -} -$xoopsLogger->stopTime('XOOPS output module - topic - quickreply'); - -$xoopsLogger->startTime('XOOPS output module - topic - tag'); -if ($xoopsModuleConfig['do_tag'] && @include_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php') { - $xoopsTpl->assign('tagbar', tagBar($topic_obj->getVar('topic_tags', 'n'))); -} -$xoopsLogger->stopTime('XOOPS output module - topic - tag'); - -$xoopsLogger->startTime('XOOPS output module - topic - transfer'); -if ($transferbar = @include XOOPS_ROOT_PATH . '/Frameworks/transfer/bar.transfer.php') { - $xoopsTpl->assign('transfer', $transferbar); -} -$xoopsLogger->stopTime('XOOPS output module - topic - transfer'); - -$xoopsLogger->stopTime('XOOPS output module - topic'); - -include XOOPS_ROOT_PATH . '/footer.php'; diff --git a/extras/newbb_4x/trunk_4_00/votepolls.php b/extras/newbb_4x/trunk_4_00/votepolls.php deleted file mode 100644 index 34b8ee0..0000000 --- a/extras/newbb_4x/trunk_4_00/votepolls.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ - -require_once __DIR__ . '/header.php'; - -$poll_id = isset($_GET['poll_id']) ? (int)$_GET['poll_id'] : 0; -$poll_id = isset($_POST['poll_id']) ? (int)$_POST['poll_id'] : $poll_id; -$topic_id = isset($_GET['topic_id']) ? (int)$_GET['topic_id'] : 0; -$topic_id = isset($_POST['topic_id']) ? (int)$_POST['topic_id'] : $topic_id; -$forum = isset($_GET['forum']) ? (int)$_GET['forum'] : 0; -$forum = isset($_POST['forum']) ? (int)$_POST['forum'] : $forum; - -/** @var NewbbTopicHandler $topicHandler */ -$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic'); -$topic_obj = $topicHandler->get($topic_id); -if (!$topicHandler->getPermission($topic_obj->getVar('forum_id'), $topic_obj->getVar('topic_status'), 'vote')) { - // irmtfan - issue with javascript:history.go(-1) - redirect_header($_SERVER['HTTP_REFERER'], 2, _NOPERM); -} - -if (empty($_POST['option_id'])) { - // irmtfan - add error message - simple url - redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_NOOPTION); -} - -/** @var XoopsModuleHandler $moduleHandler */ -$moduleHandler = xoops_getHandler('module'); -$xoopspoll = $moduleHandler->getByDirname('xoopspoll'); - -if (($xoopspoll instanceof XoopsModule) && $xoopspoll->isactive()) { - /* xoopspoll module installed & active */ - xoops_load('constants', 'xoopspoll'); - xoops_loadLanguage('main', 'xoopspoll'); - $xpPollHandler = xoops_getModuleHandler('poll', 'xoopspoll'); - $xpLogHandler = xoops_getModuleHandler('log', 'xoopspoll'); -} else { - //no active poll module found - redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_POLLMODULE_ERROR); -} - -$mail_author = false; -$pollObj = $xpPollHandler->get($poll_id); -if ($pollObj instanceof \XoopspollPoll) { - if ($pollObj->getVar('multiple')) { - $optionId = $_POST['option_id']; - $optionId = (array)$optionId; // type cast to make sure it's an array - $optionId = array_map('\intval', $optionId); // make sure values are integers - } else { - $optionId = $_POST['option_id']; - } - if (!$pollObj->hasExpired()) { - $msg = _MD_XOOPSPOLL_MUSTLOGIN; - //@todo:: add $url to all redirects - // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id)); - if ($pollObj->isAllowedToVote()) { - $thisVoter = (!empty($GLOBALS['xoopsUser']) - && ($GLOBALS['xoopsUser'] instanceof XoopsUser)) ? $GLOBALS['xoopsUser']->getVar('uid') : null; - $votedThisPoll = $xpLogHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $thisVoter); - if (!$votedThisPoll) { - /* user that hasn't voted before in this poll or module preferences allow it */ - $voteTime = time(); - if ($pollObj->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { - if (!$xpPollHandler->updateCount($pollObj)) { // update the count and save in db - echo $pollObj->getHtmlErrors(); - exit(); - } - $msg = _MD_XOOPSPOLL_THANKSFORVOTE; - } else { - /* there was a problem registering the vote */ - redirect_header($GLOBALS['xoops']->buildUrl('index.php', ['poll_id' => $poll_id]), XoopspollConstants::REDIRECT_DELAY_MEDIUM, _MD_XOOPSPOLL_VOTE_ERROR); - } - } else { - $msg = _MD_XOOPSPOLL_ALREADYVOTED; - } - /* set anon user vote (and the time they voted) */ - if (!$GLOBALS['xoopsUser'] instanceof XoopsUser) { - xoops_load('pollUtility', 'xoopspoll'); - \XoopspollPollUtility::setVoteCookie($poll_id, $voteTime, 0); - } - } else { - $msg = _MD_XOOPSPOLL_CANNOTVOTE; - } - } else { - /* poll has expired so just show the results */ - $msg = _MD_XOOPSPOLL_SORRYEXPIRED; - } -} else { - $msg = _MD_XOOPSPOLL_ERROR_INVALID_POLLID; -} -if (null !== $url) { - redirect_header($url, XoopspollConstants::REDIRECT_DELAY_MEDIUM, $msg); -} else { - redirect_header($GLOBALS['xoops']->buildUrl('viewtopic.php', ['topic_id' => $topic_id]), XoopspollConstants::REDIRECT_DELAY_MEDIUM, $msg); -} -// irmtfan - simple url -redirect_header("viewtopic.php?topic_id={$topic_id}", 1, $msg); diff --git a/extras/newbb_5x/index.html b/extras/newbb_5x/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/extras/newbb_5x/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/extras/newbb_5x/index.php b/extras/newbb_5x/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/index.php @@ -0,0 +1,3 @@ + $attach) { - if (\in_array($key, $attach_array)) { + if (\in_array($key, $attach_array, true)) { @\unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']); @\unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved']); // delete thumbnails continue; @@ -171,7 +190,7 @@ public function setAttachment($name_saved = '', $name_display = '', $mimetype = $key = (string)(\time() + $counter++); $this->attachment_array[$key] = [ 'name_saved' => $name_saved, - 'name_display' => isset($name_display) ? $name_display : $name_saved, + 'name_display' => $name_display ?? $name_saved, 'mimetype' => $mimetype, 'num_download' => isset($num_download) ? (int)$num_download : 0, ]; @@ -213,7 +232,7 @@ public function displayAttachment($asSource = false) $file_size = @\filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved'])); $file_size = \number_format($file_size / 1024, 2) . ' KB'; if ($GLOBALS['xoopsModuleConfig']['media_allowed'] - && \in_array(mb_strtolower($file_extension), $image_extensions)) { + && \in_array(mb_strtolower($file_extension), $image_extensions, true)) { $post_attachment .= '
    ' . $filetype . '  ' . $att['name_display'] . ' (' . $file_size . ')'; $post_attachment .= '
    ' . newbb_attachmentImage($att['name_saved']); $isDisplayed = true; @@ -312,8 +331,8 @@ public function displayPostEdit() if ($post_edits && \is_array($post_edits)) { foreach ($post_edits as $postedit) { $edit_time = (int)$postedit['edit_time']; - $edit_user = $myts->stripSlashesGPC($postedit['edit_user']); - $edit_msg = !empty($postedit['edit_msg']) ? $myts->stripSlashesGPC($postedit['edit_msg']) : ''; + $edit_user = ($postedit['edit_user']); + $edit_msg = !empty($postedit['edit_msg']) ? ($postedit['edit_msg']) : ''; // Start irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred) if (empty($GLOBALS['xoopsModuleConfig']['do_latestedit'])) { $post_edit = ''; @@ -443,7 +462,7 @@ public function showPost($isadmin) static $name_anonymous; if (!isset($name_anonymous)) { - $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); + $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5); } // mod_loadFunctions('time', 'newbb'); @@ -484,7 +503,7 @@ public function showPost($isadmin) $post_attachment = ''; } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply') && (!$uid - || !\in_array($uid, $viewtopic_posters))) { + || !\in_array($uid, $viewtopic_posters, true))) { $post_text = "
    " . _MD_REPLY_REQUIREMENT . "
    \n"; $post_attachment = ''; } else { @@ -495,7 +514,7 @@ public function showPost($isadmin) // Hightlighting searched words $post_title = $this->getVar('subject'); if (!empty($_GET['keywords']) && Request::hasVar('keywords', 'GET')) { - $keywords = $myts->htmlSpecialChars(\trim(\urldecode($_GET['keywords']))); + $keywords = htmlspecialchars(\trim(\urldecode($_GET['keywords'])), ENT_QUOTES | ENT_HTML5); $post_text = \newbb_highlightText($post_text, $keywords); $post_title = \newbb_highlightText($post_title, $keywords); } @@ -613,12 +632,12 @@ public function showPost($isadmin) $full_link = $GLOBALS['xoops']->url("modules/newbb/viewtopic.php?post_id={$post_id}"); $thread_action['social_twitter']['image'] = newbb_displayImage('twitter', \_MD_SHARE_TWITTER); - $thread_action['social_twitter']['link'] = "http://twitter.com/share?text={$clean_title}&url={$full_link}"; + $thread_action['social_twitter']['link'] = "https://twitter.com/share?text={$clean_title}&url={$full_link}"; $thread_action['social_twitter']['name'] = \_MD_SHARE_TWITTER; $thread_action['social_twitter']['target'] = '_blank'; $thread_action['social_facebook']['image'] = newbb_displayImage('facebook', \_MD_SHARE_FACEBOOK); - $thread_action['social_facebook']['link'] = "http://www.facebook.com/sharer.php?u={$full_link}"; + $thread_action['social_facebook']['link'] = "https://www.facebook.com/sharer.php?u={$full_link}"; $thread_action['social_facebook']['name'] = \_MD_SHARE_FACEBOOK; $thread_action['social_facebook']['target'] = '_blank'; @@ -628,27 +647,27 @@ public function showPost($isadmin) $thread_action['social_gplus']['target'] = '_blank'; $thread_action['social_linkedin']['image'] = newbb_displayImage('linkedin', \_MD_SHARE_LINKEDIN); - $thread_action['social_linkedin']['link'] = "http://www.linkedin.com/shareArticle?mini=true&title={$full_title}&url={$full_link}"; + $thread_action['social_linkedin']['link'] = "https://www.linkedin.com/shareArticle?mini=true&title={$full_title}&url={$full_link}"; $thread_action['social_linkedin']['name'] = \_MD_SHARE_LINKEDIN; $thread_action['social_linkedin']['target'] = '_blank'; $thread_action['social_delicious']['image'] = newbb_displayImage('delicious', \_MD_SHARE_DELICIOUS); - $thread_action['social_delicious']['link'] = "http://del.icio.us/post?title={$full_title}&url={$full_link}"; + $thread_action['social_delicious']['link'] = "https://del.icio.us/post?title={$full_title}&url={$full_link}"; $thread_action['social_delicious']['name'] = \_MD_SHARE_DELICIOUS; $thread_action['social_delicious']['target'] = '_blank'; $thread_action['social_digg']['image'] = newbb_displayImage('digg', \_MD_SHARE_DIGG); - $thread_action['social_digg']['link'] = "http://digg.com/submit?phase=2&title={$full_title}&url={$full_link}"; + $thread_action['social_digg']['link'] = "https://digg.com/submit?phase=2&title={$full_title}&url={$full_link}"; $thread_action['social_digg']['name'] = \_MD_SHARE_DIGG; $thread_action['social_digg']['target'] = '_blank'; $thread_action['social_reddit']['image'] = newbb_displayImage('reddit', \_MD_SHARE_REDDIT); - $thread_action['social_reddit']['link'] = "http://reddit.com/submit?title={$full_title}&url={$full_link}"; + $thread_action['social_reddit']['link'] = "https://reddit.com/submit?title={$full_title}&url={$full_link}"; $thread_action['social_reddit']['name'] = \_MD_SHARE_REDDIT; $thread_action['social_reddit']['target'] = '_blank'; $thread_action['social_wong']['image'] = newbb_displayImage('wong', \_MD_SHARE_MRWONG); - $thread_action['social_wong']['link'] = "http://www.mister-wong.de/index.php?action=addurl&bm_url=$full_link}"; + $thread_action['social_wong']['link'] = "https://www.mister-wong.de/index.php?action=addurl&bm_url=$full_link}"; $thread_action['social_wong']['name'] = \_MD_SHARE_MRWONG; $thread_action['social_wong']['target'] = '_blank'; } diff --git a/extras/newbb_5x/irmtfan/class/PostHandler.php b/extras/newbb_5x/irmtfan/class/PostHandler.php index efee80f..a2c00a6 100644 --- a/extras/newbb_5x/irmtfan/class/PostHandler.php +++ b/extras/newbb_5x/irmtfan/class/PostHandler.php @@ -1,4 +1,4 @@ -db->query($sql, $limit, 0); $ret = []; - while (false !== ($myrow = $this->db->fetchArray($result))) { - $post = $this->create(false); - $post->assignVars($myrow); + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $post = $this->create(false); + $post->assignVars($myrow); - $ret[$myrow['post_id']] = $post; - unset($post); + $ret[$myrow['post_id']] = $post; + unset($post); + } } return $ret; @@ -113,7 +111,7 @@ public function getPostForPrint($post) } /** - * @param $post + * @param mixed $post * @param bool $force * @return bool */ @@ -183,7 +181,7 @@ public function approve(&$post, $force = false) /** * @param \XoopsObject $post - * @param bool $force + * @param bool $force * @return bool */ public function insert(\XoopsObject $post, $force = true) @@ -428,8 +426,8 @@ private function _delete($post, $force = false) $poll = new \Umfrage($poll_id); if (false !== $poll->delete()) { - \UmfrageOption::deleteByPollId($poll_id); - \UmfrageLog::deleteByPollId($poll_id); + (new \UmfrageOption())->deleteByPollId($poll_id); + (new \UmfrageLog())->deleteByPollId($poll_id); \xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id); } } @@ -509,7 +507,7 @@ public function getPostCount($criteria = null, $join = null) // LEFT JOIN $sql .= $join; // WHERE - if (isset($criteria) && $criteria instanceof \CriteriaElement) { + if (\is_object($criteria) && \is_subclass_of($criteria, \CriteriaElement::class)) { $sql .= ' ' . $criteria->renderWhere(); } if (!$result = $this->db->query($sql)) { @@ -542,22 +540,20 @@ public function &getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join if (!empty($join)) { $sql .= (0 === mb_strpos($join, ' ')) ? $join : ' ' . $join; } - if (isset($criteria) && $criteria instanceof \CriteriaElement) { + if (\is_object($criteria) && \is_subclass_of($criteria, \CriteriaElement::class)) { $sql .= ' ' . $criteria->renderWhere(); if ('' !== $criteria->getSort()) { $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); } } $result = $this->db->query($sql, (int)$limit, (int)$start); - if (!$result) { - // xoops_error($this->db->error()); - return $ret; - } - while (false !== ($myrow = $this->db->fetchArray($result))) { - $post = $this->create(false); - $post->assignVars($myrow); - $ret[$myrow['post_id']] = $post; - unset($post); + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $post = $this->create(false); + $post->assignVars($myrow); + $ret[$myrow['post_id']] = $post; + unset($post); + } } return $ret; @@ -586,7 +582,6 @@ public function cleanOrphan() if ($this->mysql_major_version() >= 4) { /* for MySQL 4.1+ */ $sql = 'DELETE FROM ' . $this->db->prefix('bb_posts_text') . ' ' . 'WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM ' . $this->table . ') )'; } else { /* for 4.0+ */ - /* */ $sql = 'DELETE ' . $this->db->prefix('bb_posts_text') . ' FROM ' . $this->db->prefix('bb_posts_text') . ' ' . 'LEFT JOIN ' . $this->table . ' AS aa ON ' . $this->db->prefix('bb_posts_text') . '.post_id = aa.post_id ' . ' ' . 'WHERE (aa.post_id IS NULL)'; // Alternative for 4.1+ diff --git a/extras/newbb_5x/irmtfan/class/UserLanguage.php b/extras/newbb_5x/irmtfan/class/UserLanguage.php index 1663c89..0571984 100644 --- a/extras/newbb_5x/irmtfan/class/UserLanguage.php +++ b/extras/newbb_5x/irmtfan/class/UserLanguage.php @@ -1,10 +1,9 @@ -getVar('user_icq')) { $userbar[] = [ - 'link' => "javascript:void window.open('http://wwp.icq.com/scripts/search.dll?to=" . $user->getVar('user_icq') . "','new');", + 'link' => "javascript:void window.open('https://wwp.icq.com/scripts/search.dll?to=" . $user->getVar('user_icq') . "','new');", 'name' => _MD_ICQ, ]; } @@ -74,13 +73,13 @@ public function getUserbar() } if ($user->getVar('user_yim')) { $userbar[] = [ - 'link' => "javascript:void window.open('http://edit.yahoo.com/config/send_webmesg?.target=" . $user->getVar('user_yim') . '&.src=pg' . "','new');", + 'link' => "javascript:void window.open('https://edit.yahoo.com/config/send_webmesg?.target=" . $user->getVar('user_yim') . '&.src=pg' . "','new');", 'name' => _MD_YIM, ]; } if ($user->getVar('user_msnm')) { $userbar[] = [ - 'link' => "javascript:void window.open('http://members.msn.com?mem=" . $user->getVar('user_msnm') . "','new');", + 'link' => "javascript:void window.open('https://members.msn.com?mem=" . $user->getVar('user_msnm') . "','new');", 'name' => _MD_MSNM, ]; } diff --git a/extras/newbb_5x/irmtfan/class/index.html b/extras/newbb_5x/irmtfan/class/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_5x/irmtfan/class/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/class/index.php b/extras/newbb_5x/irmtfan/class/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/class/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/index.php b/extras/newbb_5x/irmtfan/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/language/english/index.php b/extras/newbb_5x/irmtfan/language/english/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/language/english/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/language/index.php b/extras/newbb_5x/irmtfan/language/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/language/index.php @@ -0,0 +1,3 @@ + */ @@ -47,7 +46,7 @@ 'log', ]; $op = Request::getString('op', 'add'); -$op = (!in_array($op, $goodOps)) ? 'add' : $op; +$op = (!in_array($op, $goodOps, true)) ? 'add' : $op; //$poll_id = (isset($_GET['poll_id'])) ? (int)($_GET['poll_id']) : 0; //$poll_id = (isset($_POST['poll_id'])) ? (int)($_POST['poll_id']) : $poll_id; @@ -101,7 +100,7 @@ ) { // if (('add' === $op || 'save' === $op || 'update' === $op) if (($GLOBALS['xoopsUser'] instanceof \XoopsUser) - && in_array($op, ['add', 'save', 'update']) + && in_array($op, ['add', 'save', 'update'], true) && !$topic_obj->getVar('topic_haspoll') && ($GLOBALS['xoopsUser']->getVar('uid') === $topic_obj->getVar('topic_poster'))) { $perm = true; @@ -333,7 +332,7 @@ $poll_form->addElement($weight_text); $multi_yn = new \XoopsFormRadioYN(_MD_POLL_ALLOWMULTI, 'multiple', $poll_obj->getVar('multiple')); $poll_form->addElement($multi_yn); - $options_arr = &\UmfrageOption::getAllByPollId($poll_id); + $options_arr = &(new UmfrageOption())->getAllByPollId($poll_id); $notify_value = 1; if (0 !== $poll_obj->getVar('mail_status')) { $notify_value = 0; @@ -350,7 +349,8 @@ $color_select->addOptionArray($barcolor_array); $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$pollmodules}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); $color_label = new \XoopsFormLabel( - '', "url("modules/{$pollmodules}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt=''>
    " + '', + "url("modules/{$pollmodules}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt=''>
    " ); $option_tray->addElement($color_select); $option_tray->addElement($color_label); @@ -489,10 +489,10 @@ $poll_obj->setVar('multiple', (int)(@$_POST['multiple'])); if (!empty($_POST['notify']) && $end_time > time()) { // if notify, set mail status to 'not mailed' - $poll_obj->setVar('mail_status', POLL_NOT_MAILED); + $poll_obj->setVar('mail_status', Constants::POLL_NOT_MAILED); } else { // if not notify, set mail status to already "mailed" - $poll_obj->setVar('mail_status', POLL_MAILED); + $poll_obj->setVar('mail_status', Constants::POLL_MAILED); } if (!$poll_obj->store()) { @@ -511,7 +511,7 @@ $option_obj->store(); } else { if (false !== $option_obj->delete()) { - \UmfrageLog::deleteByOptionId($option->getVar('option_id')); + (new UmfrageLog())->deleteByOptionId($option->getVar('option_id')); } } ++$i; @@ -652,8 +652,8 @@ $poll_obj = new \Umfrage($poll_id); $status = $poll_obj->delete(); if (false !== $status) { - \UmfrageOption::deleteByPollId($poll_id); - \UmfrageLog::deleteByPollId($poll_id); + (new UmfrageOption())->deleteByPollId($poll_id); + (new UmfrageLog())->deleteByPollId($poll_id); } else { $msg = $poll_obj->getHtmlErrors(); } @@ -720,8 +720,8 @@ } else { // Umfrage $poll_obj = new \Umfrage($poll_id); $default_poll_duration = (86400 * 10); - $poll_not_mailed = POLL_NOT_MAILED; - $poll_mailed = POLL_MAILED; + $poll_not_mailed = Constants::POLL_NOT_MAILED; + $poll_mailed = Constants::POLL_MAILED; } $end_time = Request::getInt('end_time', 0, 'POST'); @@ -759,8 +759,8 @@ exit(); } if (Request::hasVar('reset', 'POST')) { // reset all logs - \UmfrageLog::deleteByPollId($poll_id); - \UmfrageOption::resetCountByPollId($poll_id); + (new UmfrageLog())->deleteByPollId($poll_id); + (new UmfrageOption())->resetCountByPollId($poll_id); $poll_obj->updateCount(); } } diff --git a/extras/newbb_5x/irmtfan/templates/css/index.html b/extras/newbb_5x/irmtfan/templates/css/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_5x/irmtfan/templates/css/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/templates/css/index.php b/extras/newbb_5x/irmtfan/templates/css/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/templates/css/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/templates/css/language/english/index.php b/extras/newbb_5x/irmtfan/templates/css/language/english/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/templates/css/language/english/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/templates/css/language/index.php b/extras/newbb_5x/irmtfan/templates/css/language/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/templates/css/language/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/templates/css/language/persian/index.php b/extras/newbb_5x/irmtfan/templates/css/language/persian/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/templates/css/language/persian/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/irmtfan/templates/index.php b/extras/newbb_5x/irmtfan/templates/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/irmtfan/templates/index.php @@ -0,0 +1,3 @@ +delete()) { - UmfrageOption::deleteByPollId($poll_id); - UmfrageLog::deleteByPollId($poll_id); + (new UmfrageOption())->deleteByPollId($poll_id); + (new UmfrageLog())->deleteByPollId($poll_id); xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); } } diff --git a/extras/newbb_5x/irmtfan/viewtopic.php b/extras/newbb_5x/irmtfan/viewtopic.php index 0824c9a..e2d2e80 100644 --- a/extras/newbb_5x/irmtfan/viewtopic.php +++ b/extras/newbb_5x/irmtfan/viewtopic.php @@ -1,4 +1,4 @@ - */ @@ -69,9 +68,9 @@ $move = isset($_GET['move']) ? mb_strtolower($_GET['move']) : ''; $start = Request::getInt('start', 0, 'GET'); $status = (!empty($_GET['status']) - && in_array($_GET['status'], ['active', 'pending', 'deleted'])) ? $_GET['status'] : ''; + && in_array($_GET['status'], ['active', 'pending', 'deleted'], true)) ? $_GET['status'] : ''; $mode = Request::getInt('mode', (!empty($status) ? 2 : 0), 'GET'); -$order = (!empty($_GET['order']) && in_array($_GET['order'], ['ASC', 'DESC'])) ? $_GET['order'] : ''; +$order = (!empty($_GET['order']) && in_array($_GET['order'], ['ASC', 'DESC'], true)) ? $_GET['order'] : ''; if ('' === $order) { if (($xoopsUser instanceof \XoopsUser) && $xoopsUser->isActive()) { @@ -104,7 +103,8 @@ $forum_id = $topic_obj->getVar('forum_id'); /** @var Newbb\ForumHandler $forumHandler */ $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); -$forum_obj = $forumHandler->get($forum_id); +/** @var Newbb\Forum $forum_obj */ +$forum_obj = $forumHandler->get($forum_id); $isadmin = newbb_isAdmin($forum_obj); @@ -178,7 +178,7 @@ 'xoops_module_header', ' - ' . @$xoopsTpl->get_template_vars('xoops_module_header') + ' . @$xoopsTpl->getTemplateVars('xoops_module_header') ); } @@ -254,7 +254,7 @@ } } // irmtfan for backward compatibility assign forum_post_or_register smarty again. -$xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->get_template_vars('forum_post') . @$xoopsTpl->get_template_vars('forum_register') . @$xoopsTpl->get_template_vars('topic_lock')); +$xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->getTemplateVars('forum_post') . @$xoopsTpl->getTemplateVars('forum_register') . @$xoopsTpl->getTemplateVars('topic_lock')); if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'reply')) { $xoopsTpl->assign('forum_reply', '' . $t_reply . ''); @@ -274,6 +274,7 @@ $userid_array = []; $online = []; if (count($poster_array) > 0) { + /** @var \XoopsMemberHandler $memberHandler */ $memberHandler = xoops_getHandler('member'); $userid_array = array_keys($poster_array); $user_criteria = '(' . implode(',', $userid_array) . ')'; @@ -465,14 +466,14 @@ } // END irmtfan add restore to viewtopic -$xoopsTpl->assign_by_ref('admin_actions', $admin_actions); +$xoopsTpl->assignByRef('admin_actions', $admin_actions); $xoopsTpl->assign('viewer_level', (int)($isadmin ? 2 : is_object($xoopsUser))); if ($GLOBALS['xoopsModuleConfig']['show_permissiontable']) { /** @var Newbb\PermissionHandler $permHandler */ - $permissionHandler = Newbb\Helper::getInstance()->getHandler('Permission'); - $permission_table = $permissionHandler->getPermissionTable($forum_obj, $topic_obj->getVar('topic_status'), $isadmin); - $xoopsTpl->assign_by_ref('permission_table', $permission_table); + $permissionHandler = Newbb\Helper::getInstance()->getHandler('Permission'); + $permission_table = $permissionHandler->getPermissionTable($forum_obj, $topic_obj->getVar('topic_status'), $isadmin); + $xoopsTpl->assignByRef('permission_table', $permission_table); } // Show poll @@ -507,6 +508,7 @@ $visibleMsg = $isVisible ? '' : $vis_return; /* setup the module config handler */ + /** @var \XoopsConfigHandler $configHandler */ $configHandler = xoops_getHandler('config'); $xp_config = $configHandler->getConfigsByCat(0, $xoopspoll->getVar('mid')); @@ -548,7 +550,7 @@ $poll_obj = new \Umfrage($topic_obj->getVar('poll_id')); $hasEnded = $poll_obj->getVar('end_time') < time(); $renderer = new \UmfrageRenderer($poll); - $xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2); + $xoopsTpl->assign('lang_alreadyvoted2', _MD_XOOPSPOLL_ALREADYVOTED); $xoopsTpl->assign('has_ended', $hasEnded); $xoopsTpl->assign('polltype', $poll_obj->getVar('polltype')); switch ($poll_obj->getVar('polltype')) { @@ -568,7 +570,7 @@ $hasvoted = 0; if ($uid > 0) { - if (\UmfrageLog::hasVoted($topic_obj->getVar('poll_id'), xoops_getenv('REMOTE_ADDR'), $uid)) { + if ((new UmfrageLog())->hasVoted($topic_obj->getVar('poll_id'), xoops_getenv('REMOTE_ADDR'), $uid)) { $hasvoted = 1; } } else { @@ -585,7 +587,7 @@ ] ); - if (\UmfrageLog::hasVoted($topic_obj->getVar('poll_id'), $_SERVER['REMOTE_ADDR'], $uid) + if ((new UmfrageLog())->hasVoted($topic_obj->getVar('poll_id'), $_SERVER['REMOTE_ADDR'], $uid) || $poll_obj->getVar('end_time') < time()) { $renderer->assignResults($xoopsTpl); //pollresults($forumtopic->getVar('poll_id')); @@ -629,7 +631,7 @@ 'name' => _MD_RESTARTPOLL, ]; - $xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions); + $xoopsTpl->assignByRef('adminpoll_actions', $adminpoll_actions); } } if (isset($poll_obj)) { @@ -733,7 +735,7 @@ ); //$xoopsTpl->assign('viewmode_compact', ($viewmode=="compact")?1:0); // changed to assign, assign_by_ref not supported under PHP 5.x -//$xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options); +//$xoopsTpl->assignByRef('viewmode_options', $viewmode_options); //unset($viewmode_options); // START irmtfan add verifyUser to quick reply @@ -745,8 +747,9 @@ // END irmtfan add verifyUser to quick reply $forum_form = new \XoopsThemeForm(_MD_POSTREPLY, 'quick_reply', $GLOBALS['xoops']->url('modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php'), 'post', true); if (!$xoopsUser instanceof \XoopsUser) { - //$configHandler = xoops_getHandler('config'); - $user_tray = new \XoopsFormElementTray(_MD_ACCOUNT); + ///** @var \XoopsConfigHandler $configHandler */ + $configHandler = xoops_getHandler('config'); + $user_tray = new \XoopsFormElementTray(_MD_ACCOUNT); $user_tray->addElement(new \XoopsFormText(_MD_NAME, 'uname', 26, 255)); $user_tray->addElement(new \XoopsFormPassword(_MD_PASSWORD, 'pass', 10, 32)); $login_checkbox = new \XoopsFormCheckBox('', 'login', 1); @@ -803,7 +806,7 @@ 'collapse' => $iconHandler->getImageSource($qr_collapse), ]; $quickreply['show'] = 1; // = !empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled'] - $quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles) ? false : true) : true; + $quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles, true) ? false : true) : true; if ($quickreply['expand']) { $quickreply['style'] = 'block'; //irmtfan move semicolon $quickreply_icon_display = $qr_expand; @@ -822,19 +825,11 @@ $xoopsTpl->assign('quickreply', ['show' => 0]); } -if ($GLOBALS['xoopsModuleConfig']['do_tag']) { - // now make sure tag module exists and is active - /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $tagModule = $moduleHandler->getByDirname('tag'); - if ($tagModule instanceof \XoopsModule && $tagModule->isactive()) { - @require_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php'); - $xoopsTpl->assign('tagbar', tagBar($topic_obj->getVar('topic_tags', 'n'))); - } else { - $xoopsTpl->assign('tagbar', ''); - } -} else { - $xoopsTpl->assign('tagbar', ''); +$xoopsTpl->assign('tagbar', ''); +$helper = Helper::getInstance(); +if (1 == $helper->getConfig('do_tag') && \class_exists(\XoopsModules\Tag\Tagbar::class) && \xoops_isActiveModule('tag')) { + $tagbarObj = new \XoopsModules\Tag\Tagbar(); + $xoopsTpl->assign('tagbar', $tagbarObj->getTagbar($topic_obj->getVar('topic_tags', 'n'))); } // irmtfan move to footer.php require_once __DIR__ . '/footer.php'; diff --git a/extras/newbb_5x/irmtfan/votepolls.php b/extras/newbb_5x/irmtfan/votepolls.php index cbc49a8..29bdb40 100644 --- a/extras/newbb_5x/irmtfan/votepolls.php +++ b/extras/newbb_5x/irmtfan/votepolls.php @@ -1,4 +1,4 @@ -getVar('uid'))) { + if ((new UmfrageLog())->hasVoted($poll_id, $_SERVER['REMOTE_ADDR'], $xoopsUser->getVar('uid'))) { $msg = _PL_ALREADYVOTED; setcookie("bb_polls[$poll_id]", 1); } else { @@ -137,7 +135,7 @@ setcookie("bb_polls[$poll_id]", 1); } } else { - if (\UmfrageLog::hasVoted($poll_id, $_SERVER['REMOTE_ADDR'])) { + if ((new UmfrageLog())->hasVoted($poll_id, $_SERVER['REMOTE_ADDR'])) { $msg = _PL_ALREADYVOTED; setcookie("bb_polls[$poll_id]", 1); } else { diff --git a/extras/newbb_5x/trunk_5_00/class/Post.php b/extras/newbb_5x/trunk_5_00/class/Post.php index 912cd61..5b30e0c 100644 --- a/extras/newbb_5x/trunk_5_00/class/Post.php +++ b/extras/newbb_5x/trunk_5_00/class/Post.php @@ -1,4 +1,5 @@ - */ @@ -19,11 +19,34 @@ use XoopsModules\Newbb; use XoopsModules\Xoopspoll; - /** +/** * Class post */ class Post extends \XoopsObject { + private $post_id; + private $topic_id; + private $forum_id; + private $post_time; + private $poster_ip; + private $poster_name; + private $subject; + private $pid; + private $dohtml; + private $dosmiley; + private $doxcode; + private $doimage; + private $dobr; + private $uid; + private $icon; + private $attachsig; + private $approved; + private $post_karma; + private $require_reply; + private $attachment; + private $post_text; + private $post_edit; + public $attachment_array = []; /** @@ -133,7 +156,7 @@ public function deleteAttachment($attach_array = null) } foreach ($attach_old as $key => $attach) { - if (in_array($key, $attach_array)) { + if (in_array($key, $attach_array, true)) { @unlink(XOOPS_ROOT_PATH . '/' . $helper->getConfig('dir_attachments') . '/' . $attach['name_saved']); @unlink(XOOPS_ROOT_PATH . '/' . $helper->getConfig('dir_attachments') . '/thumbs/' . $attach['name_saved']); // delete thumbnails continue; @@ -164,7 +187,7 @@ public function setAttachment($name_saved = '', $name_display = '', $mimetype = $key = (string)(time() + $counter++); $this->attachment_array[$key] = [ 'name_saved' => $name_saved, - 'name_display' => isset($name_display) ? $name_display : $name_saved, + 'name_display' => $name_display ?? $name_saved, 'mimetype' => $mimetype, 'num_download' => isset($num_download) ? (int)$num_download : 0, ]; @@ -208,7 +231,7 @@ public function displayAttachment($asSource = false) } $file_size = @filesize(XOOPS_ROOT_PATH . '/' . $helper->getConfig('dir_attachments') . '/' . $att['name_saved']); $file_size = number_format($file_size / 1024, 2) . ' KB'; - if (in_array(mb_strtolower($file_extension), $image_extensions) && $helper->getConfig('media_allowed')) { + if (in_array(mb_strtolower($file_extension), $image_extensions, true) && $helper->getConfig('media_allowed')) { $post_attachment .= '
    ' . $filetype . '  ' . $att['name_display'] . ' (' . $file_size . ')'; $post_attachment .= '
    ' . newbb_attachmentImage($att['name_saved']); $isDisplayed = true; @@ -311,7 +334,7 @@ public function displayPostEdit() if ($post_edits && is_array($post_edits)) { foreach ($post_edits as $postedit) { $edit_time = (int)$postedit['edit_time']; - $edit_user = $myts->stripSlashesGPC($postedit['edit_user']); + $edit_user = ($postedit['edit_user']); $post_edit .= _MD_EDITEDBY . ' ' . $edit_user . ' ' . _MD_ON . ' ' . formatTimestamp($edit_time) . '
    '; } } @@ -349,6 +372,7 @@ public function &getPostBody() } else { $post['text'] = $post_text . '
    ' . $this->displayAttachment(); } + /** @var \XoopsMemberHandler $memberHandler */ $memberHandler = xoops_getHandler('member'); $eachposter = $memberHandler->getUser($this->getVar('uid')); if (is_object($eachposter) && $eachposter->isActive()) { @@ -432,7 +456,7 @@ public function showPost($isadmin) static $name_anonymous; if (!isset($name_anonymous)) { - $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); + $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5); } require_once XOOPS_ROOT_PATH . '/modules/newbb/include/functions.time.php'; @@ -469,7 +493,7 @@ public function showPost($isadmin) $post_attachment = ''; } elseif ($helper->getConfig('allow_require_reply') && $this->getVar('require_reply') && (!$uid - || !in_array($uid, $viewtopic_posters))) { + || !in_array($uid, $viewtopic_posters, true))) { $post_text = "
    " . _MD_REPLY_REQUIREMENT . '
    '; $post_attachment = ''; } else { @@ -626,12 +650,14 @@ public function &getByLimit($topic_id, $limit, $approved = 1) . ' ORDER BY p.post_time DESC'; $result = $this->db->query($sql, $limit, 0); $ret = []; - while (false !== ($myrow = $this->db->fetchArray($result))) { - $post = $this->create(false); - $post->assignVars($myrow); + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $post = $this->create(false); + $post->assignVars($myrow); - $ret[$myrow['post_id']] = $post; - unset($post); + $ret[$myrow['post_id']] = $post; + unset($post); + } } return $ret; @@ -656,7 +682,7 @@ public function getPostForPrint($post) } /** - * @param $post + * @param \XoopsObject $post * @param bool $force * @return bool */ @@ -705,6 +731,7 @@ public function approve(&$post, $force = false) // Update user stats if ($post->getVar('uid') > 0) { + /** @var \XoopsMemberHandler $memberHandler */ $memberHandler = xoops_getHandler('member'); $poster = $memberHandler->getUser($post->getVar('uid')); if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) { @@ -726,7 +753,7 @@ public function approve(&$post, $force = false) /** * @param \XoopsObject $post - * @param bool $force + * @param bool $force * @return bool */ public function insert(\XoopsObject $post, $force = true) @@ -836,8 +863,8 @@ public function insert(\XoopsObject $post, $force = true) /** * @param \XoopsObject $post - * @param bool $isDeleteOne - * @param bool $force + * @param bool $isDeleteOne + * @param bool $force * @return bool */ public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false) @@ -963,6 +990,7 @@ public function _delete($post, $force = false) if ($postcount_toupdate > 0) { // Update user stats if ($post->getVar('uid') > 0) { + /** @var \XoopsMemberHandler $memberHandler */ $memberHandler = xoops_getHandler('member'); $poster = $memberHandler->getUser($post->getVar('uid')); if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) { @@ -1008,22 +1036,20 @@ public function &getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join if (!empty($join)) { $sql .= $join; } - if (isset($criteria) && $criteria instanceof \CriteriaElement) { + if (\is_object($criteria) && \is_subclass_of($criteria, \CriteriaElement::class)) { $sql .= ' ' . $criteria->renderWhere(); if ('' != $criteria->getSort()) { $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); } } $result = $this->db->query($sql, (int)$limit, (int)$start); - if (!$result) { - //xoops_error($this->db->error()); - return $ret; - } - while (false !== ($myrow = $this->db->fetchArray($result))) { - $post = $this->create(false); - $post->assignVars($myrow); - $ret[$myrow['post_id']] = $post; - unset($post); + if ($result) { + while (false !== ($myrow = $this->db->fetchArray($result))) { + $post = $this->create(false); + $post->assignVars($myrow); + $ret[$myrow['post_id']] = $post; + unset($post); + } } return $ret; diff --git a/extras/newbb_5x/trunk_5_00/class/index.html b/extras/newbb_5x/trunk_5_00/class/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_5x/trunk_5_00/class/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_5x/trunk_5_00/class/index.php b/extras/newbb_5x/trunk_5_00/class/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/trunk_5_00/class/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/trunk_5_00/index.php b/extras/newbb_5x/trunk_5_00/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/trunk_5_00/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/extras/newbb_5x/trunk_5_00/language/index.php b/extras/newbb_5x/trunk_5_00/language/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/trunk_5_00/language/index.php @@ -0,0 +1,3 @@ + */ @@ -47,7 +46,7 @@ 'log', ]; $op = Request::getString('op', 'add'); -$op = (!in_array($op, $goodOps)) ? 'add' : $op; +$op = (!in_array($op, $goodOps, true)) ? 'add' : $op; //$poll_id = (isset($_GET['poll_id'])) ? (int)($_GET['poll_id']) : 0; //$poll_id = (isset($_POST['poll_id'])) ? (int)($_POST['poll_id']) : $poll_id; diff --git a/extras/newbb_5x/trunk_5_00/templates/index.html b/extras/newbb_5x/trunk_5_00/templates/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/extras/newbb_5x/trunk_5_00/templates/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/extras/newbb_5x/trunk_5_00/templates/index.php b/extras/newbb_5x/trunk_5_00/templates/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/newbb_5x/trunk_5_00/templates/index.php @@ -0,0 +1,3 @@ + */ diff --git a/extras/newbb_5x/trunk_5_00/viewtopic.php b/extras/newbb_5x/trunk_5_00/viewtopic.php index 794da46..6779c88 100644 --- a/extras/newbb_5x/trunk_5_00/viewtopic.php +++ b/extras/newbb_5x/trunk_5_00/viewtopic.php @@ -1,4 +1,5 @@ - */ @@ -47,7 +47,7 @@ $move = isset($_GET['move']) ? mb_strtolower($_GET['move']) : ''; $start = Request::getInt('start', 0, 'GET'); $status = (!empty($_GET['status']) - && in_array($_GET['status'], ['active', 'pending', 'deleted'])) ? $_GET['status'] : ''; + && in_array($_GET['status'], ['active', 'pending', 'deleted'], true)) ? $_GET['status'] : ''; $mode = Request::getInt('mode', (!empty($status) ? 2 : 0), 'GET'); if (!$topic_id && !$post_id) { @@ -100,13 +100,13 @@ $valid_modes = $helper->getConfig('valid_viewmodes'); $viewmode_cookie = newbb_getcookie('V'); -if (Request::hasVar('viewmode', 'GET') && in_array($_GET['viewmode'], $valid_modes)) { +if (Request::hasVar('viewmode', 'GET') && in_array($_GET['viewmode'], $valid_modes, true)) { newbb_setcookie('V', $_GET['viewmode'], $forumCookie['expire']); } $viewmode = $_GET['viewmode'] ?? (!empty($viewmode_cookie) ? $viewmode_cookie : @$valid_modes[$helper->getConfig('view_mode') - 1]); -$viewmode = @in_array($viewmode, $valid_modes) ? $viewmode : $valid_modes[0]; +$viewmode = @in_array($viewmode, $valid_modes, true) ? $viewmode : $valid_modes[0]; $order = (isset($_GET['order']) - && in_array(mb_strtoupper($_GET['order']), ['DESC', 'ASC'])) ? $_GET['order'] : 'ASC'; + && in_array(mb_strtoupper($_GET['order']), ['DESC', 'ASC'], true)) ? $_GET['order'] : 'ASC'; $total_posts = $topicHandler->getPostCount($topic_obj, $status); @@ -200,6 +200,7 @@ $userid_array = []; $online = []; if (count($poster_array) > 0) { + /** @var \XoopsMemberHandler $memberHandler */ $memberHandler = xoops_getHandler('member'); $userid_array = array_keys($poster_array); //$user_criteria = "(" . implode(",", $userid_array) . ")"; @@ -363,14 +364,14 @@ 'name' => _MD_UNDIGESTTOPIC, ]; } -$xoopsTpl->assign_by_ref('admin_actions', $admin_actions); +$xoopsTpl->assignByRef('admin_actions', $admin_actions); $xoopsTpl->assign('viewer_level', $isadmin ? 2 : is_object($xoopsUser)); if ($helper->getConfig('show_permissiontable')) { - $permissionHandler = Newbb\Helper::getInstance()->getHandler('Permission'); - $permission_table = $permissionHandler->getPermissionTable($forum_obj, $topic_obj->getVar('topic_status'), $isadmin); - $xoopsTpl->assign_by_ref('permission_table', $permission_table); + $permissionHandler = Newbb\Helper::getInstance()->getHandler('Permission'); + $permission_table = $permissionHandler->getPermissionTable($forum_obj, $topic_obj->getVar('topic_status'), $isadmin); + $xoopsTpl->assignByRef('permission_table', $permission_table); } /////////////////////////////// @@ -401,6 +402,7 @@ $visibleMsg = $isVisible ? '' : $vis_return; /* setup the module config handler */ + /** @var \XoopsConfigHandler $configHandler */ $configHandler = xoops_getHandler('config'); $xp_config = $configHandler->getConfigsByCat(0, $xoopspoll->getVar('mid')); @@ -461,7 +463,7 @@ 'name' => _MD_RESTARTPOLL, ]; - $xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions); + $xoopsTpl->assignByRef('adminpoll_actions', $adminpoll_actions); } } if (isset($poll_obj)) { @@ -585,7 +587,7 @@ $xoopsTpl->assign('mode', $mode); $xoopsTpl->assign('status', $status); $xoopsTpl->assign('viewmode_compact', ('compact' === $viewmode) ? 1 : 0); -$xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options); +$xoopsTpl->assignByRef('viewmode_options', $viewmode_options); unset($viewmode_options); $xoopsTpl->assign('menumode', $menumode); $xoopsTpl->assign('menumode_other', $menumode_other); @@ -613,6 +615,7 @@ require_once XOOPS_ROOT_PATH . '/class/xoopsform/formtext.php'; require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelementtray.php'; require_once XOOPS_ROOT_PATH . '/Frameworks/captcha/formcaptcha.php'; + /** @var \XoopsConfigHandler $configHandler */ $configHandler = xoops_getHandler('config'); $user_tray = new \XoopsFormElementTray(_MD_ACCOUNT); $user_tray->addElement(new \XoopsFormText(_MD_NAME, 'uname', 26, 255)); @@ -658,7 +661,7 @@ $forum_form->addElement($submit_button); $toggles = newbb_getcookie('G', true); - $display = in_array('qr', $toggles) ? 'none;' : 'block;'; + $display = in_array('qr', $toggles, true) ? 'none;' : 'block;'; $xoopsTpl->assign( 'quickreply', [ @@ -676,8 +679,9 @@ $xoopsLogger->stopTime('XOOPS output module - topic - quickreply'); $xoopsLogger->startTime('XOOPS output module - topic - tag'); -if ($helper->getConfig('do_tag') && @require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php') { - $xoopsTpl->assign('tagbar', tagBar($topic_obj->getVar('topic_tags', 'n'))); +if (1 == $helper->getConfig('do_tag') && \class_exists(\XoopsModules\Tag\Tagbar::class) && \xoops_isActiveModule('tag')) { + $tagbarObj = new \XoopsModules\Tag\Tagbar(); + $xoopsTpl->assign('tagbar', $tagbarObj->getTagbar($topic_obj->getVar('topic_tags', 'n'))); } $xoopsLogger->stopTime('XOOPS output module - topic - tag'); diff --git a/extras/newbb_5x/trunk_5_00/votepolls.php b/extras/newbb_5x/trunk_5_00/votepolls.php index a5b2a6d..d3f2b3d 100644 --- a/extras/newbb_5x/trunk_5_00/votepolls.php +++ b/extras/newbb_5x/trunk_5_00/votepolls.php @@ -1,4 +1,5 @@ - */ diff --git a/extras/smartclone/index.html b/extras/smartclone/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/extras/smartclone/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/extras/smartclone/index.php b/extras/smartclone/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/smartclone/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/extras/smartclone/plugins/index.php b/extras/smartclone/plugins/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/extras/smartclone/plugins/index.php @@ -0,0 +1,3 @@ +getModule()->getInfo('modicons16'); //$pathModIcon32 = $helper->getModule()->getInfo('modicons32'); @@ -85,7 +84,7 @@ $GLOBALS['xoopsTpl'] = new \XoopsTpl(); } -$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); +$GLOBALS['xoopsTpl']->assign('mod_url', $helper->url()); // Local icons path if (is_object($helper->getModule())) { $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); @@ -94,3 +93,19 @@ $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); } + +xoops_loadLanguage('main', $moduleDirName); +if (class_exists('D3LanguageManager')) { + require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php'; + $langman = D3LanguageManager::getInstance(); + $langman->read('main.php', $moduleDirName); +} + + + +xoops_loadLanguage('main', $moduleDirName); +if (class_exists('D3LanguageManager')) { + require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php'; + $langman = D3LanguageManager::getInstance(); + $langman->read('main.php', $moduleDirName); +} diff --git a/include/config.php b/include/config.php index 39d6df2..79dca43 100644 --- a/include/config.php +++ b/include/config.php @@ -1,4 +1,4 @@ - $moduleDirNameUpper . ' Module Configurator', @@ -79,6 +79,5 @@ // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]), ], 'modCopyright' => " - \'XOOPS', + \'XOOPS', ]; - diff --git a/include/index.html b/include/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/include/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/include/index.php b/include/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/include/index.php @@ -0,0 +1,3 @@ + - * @param \XoopsModule $module - * @return bool */ -function xoops_module_pre_install_xoopspoll(\XoopsModule $module) +function xoops_module_pre_install_xoopspoll(\XoopsModule $module): bool { // $db = \XoopsDatabaseFactory::getDatabaseConnection(); $retVal = true; @@ -32,7 +29,7 @@ function xoops_module_pre_install_xoopspoll(\XoopsModule $module) * @param \XoopsModule $module * @return bool */ -function xoops_module_install_xoopspoll(\XoopsModule $module) +function xoops_module_install_xoopspoll(\XoopsModule $module): bool { $retVal = true; diff --git a/include/onuninstall.php b/include/onuninstall.php index 5966d9b..33f0c8e 100644 --- a/include/onuninstall.php +++ b/include/onuninstall.php @@ -1,4 +1,4 @@ - * @param XoopsModule $module @@ -30,7 +29,7 @@ * @param \XoopsModule $module * @return bool */ -function xoops_module_pre_uninstall_xoopspoll(\XoopsModule $module) +function xoops_module_pre_uninstall_xoopspoll(\XoopsModule $module): bool { /* make sure that any polls associated with xoopspoll are cleared from newbb */ /** @var \XoopsModuleHandler $moduleHandler */ @@ -53,10 +52,10 @@ function xoops_module_pre_uninstall_xoopspoll(\XoopsModule $module) * @param XoopsModule $module * @return bool */ -function xoops_module_uninstall_xoopspoll(\XoopsModule $module) +function xoops_module_uninstall_xoopspoll(\XoopsModule $module): bool { /* clear the voted cookie(s) for the admin user's machine when module is uninstalled */ - $success = Utility::setVoteCookie('', null, time() - 3600); + $success = Utility::setVoteCookie('', '', time() - 3600); return $success; } diff --git a/include/onupdate.php b/include/onupdate.php index d43ad4b..bd68c24 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -1,4 +1,4 @@ - */ @@ -24,14 +23,13 @@ Utility }; - /** * @param \XoopsDatabase|null $db * @param $fromTable * @param $toTable * @return bool */ -function xoopspollChangeTableName(\XoopsDatabase $db, $fromTable, $toTable) +function xoopspollChangeTableName(\XoopsDatabase $db, $fromTable, $toTable): bool { $fromTable = addslashes($fromTable); $toTable = addslashes($toTable); @@ -39,10 +37,10 @@ function xoopspollChangeTableName(\XoopsDatabase $db, $fromTable, $toTable) $fromThisTable = $db->prefix("{$fromTable}"); $toThisTable = $db->prefix("{$toTable}"); */ - $helper = Helper::getInstance(); + $helper = Helper::getInstance(); $success = false; if (Utility::dbTableExists($db, $fromTable) && !Utility::dbTableExists($db, $toTable)) { - $sql = sprintf('ALTER TABLE ' . $db->prefix((string)$fromTable) . ' RENAME ' . $db->prefix('{$toTable}')); + $sql = 'ALTER TABLE ' . $db->prefix((string)$fromTable) . ' RENAME ' . $db->prefix('{$toTable}'); $success = $db->queryF($sql); if (false === $success) { $moduleHandler = $helper->getHandler('Module'); @@ -55,16 +53,16 @@ function xoopspollChangeTableName(\XoopsDatabase $db, $fromTable, $toTable) } /** - * @param \XoopsModule $module + * @param \XoopsModule $module * @param $prev_version * @return bool */ -function xoops_module_update_xoopspoll(\XoopsModule $module, $prev_version) +function xoops_module_update_xoopspoll(\XoopsModule $module, $prev_version): bool { // referer check $success = false; $ref = xoops_getenv('HTTP_REFERER'); - $helper = Helper::getInstance(); + $helper = Helper::getInstance(); if (('' === $ref) || 0 === mb_strpos($ref, $GLOBALS['xoops']->url('modules/system/admin.php'))) { /* module specific part */ require_once $helper->path('include/oninstall.php'); diff --git a/include/search.php b/include/search.php index 86732f7..611b3f6 100644 --- a/include/search.php +++ b/include/search.php @@ -1,4 +1,4 @@ - @@ -25,21 +24,19 @@ Helper }; - - /** * xoopspoll_search() * * @param $queryArray - * @param mixed $andor - * @param mixed $limit - * @param mixed $offset + * @param mixed $andor + * @param mixed $limit + * @param mixed $offset * @param $uid * @return array * @internal param mixed $queryarray * @internal param mixed $userid */ -function xoopspoll_search($queryArray, $andor, $limit, $offset, $uid) +function xoopspoll_search($queryArray, mixed $andor, mixed $limit, mixed $offset, $uid): array { $ret = []; if (0 === (int)$uid) { @@ -48,24 +45,25 @@ function xoopspoll_search($queryArray, $andor, $limit, $offset, $uid) $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('start_time', time(), '<=')); // only show polls that have started - /** + /** * @todo: - * find out if want to show polls that were created with a forum. If no, then change + * find out if you want to show polls that were created with a forum. If no, then change * the link to forum topic_id */ /** * check to see if we want to include polls created with forum (newbb) */ - $configHandler = xoops_getHandler('config'); + /** @var \XoopsConfigHandler $configHandler */ + $configHandler = xoops_getHandler('config'); /** @var \XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $thisModule = $moduleHandler->getByDirname('xoopspoll'); - $this_module_config = $configHandler->getConfigsByCat(0, $thisModule->getVar('mid')); + $moduleHandler = xoops_getHandler('module'); + $thisModule = $moduleHandler->getByDirname('xoopspoll'); + $thisModuleConfig = $configHandler->getConfigsByCat(0, $thisModule->getVar('mid')); $pollsWithTopics = []; if (($thisModule instanceof \XoopsModule) && $thisModule->isactive() - && $this_module_config['hide_forum_polls']) { + && $thisModuleConfig['hide_forum_polls']) { $newbbModule = $moduleHandler->getByDirname('newbb'); if ($newbbModule instanceof \XoopsModule && $newbbModule->isactive()) { /** @var Newbb\TopicHandler $topicHandler */ diff --git a/index.php b/index.php index 7c5ce2f..3b41f6c 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ -getHandler('Poll'); $logHandler = $helper->getHandler('Log'); @@ -69,17 +69,17 @@ require $GLOBALS['xoops']->path('header.php'); $GLOBALS['xoopsTpl']->assign( [ - 'lang_pollslist' => _MD_XOOPSPOLL_POLLSLIST, - 'lang_pollquestion' => _MD_XOOPSPOLL_POLLQUESTION, - 'lang_pollvoters' => _MD_XOOPSPOLL_VOTERS, - 'lang_votes' => _MD_XOOPSPOLL_VOTES, - 'lang_expiration' => _MD_XOOPSPOLL_EXPIRATION, - 'lang_results' => _MD_XOOPSPOLL_RESULTS, - 'lang_mustlogin' => _MD_XOOPSPOLL_MUSTLOGIN, - 'disp_votes' => $GLOBALS['xoopsModuleConfig']['disp_vote_nums'], - 'results_link_icon' => \Xmf\Module\Admin::iconUrl('', 16) . '/open12.gif', - 'obscured_icon' => $GLOBALS['xoops']->url('modules/xoopspoll/assets/images/icons/obscured.png'), - 'lang_obscured_alt' => _MD_XOOPSPOLL_OBSCURED, + 'lang_pollslist' => _MD_XOOPSPOLL_POLLSLIST, + 'lang_pollquestion' => _MD_XOOPSPOLL_POLLQUESTION, + 'lang_pollvoters' => _MD_XOOPSPOLL_VOTERS, + 'lang_votes' => _MD_XOOPSPOLL_VOTES, + 'lang_expiration' => _MD_XOOPSPOLL_EXPIRATION, + 'lang_results' => _MD_XOOPSPOLL_RESULTS, + 'lang_mustlogin' => _MD_XOOPSPOLL_MUSTLOGIN, + 'disp_votes' => $GLOBALS['xoopsModuleConfig']['disp_vote_nums'], + 'results_link_icon' => Admin::iconUrl('', '16') . '/open12.gif', + 'obscured_icon' => $GLOBALS['xoops']->url('modules/xoopspoll/assets/images/icons/obscured.png'), + 'lang_obscured_alt' => _MD_XOOPSPOLL_OBSCURED, 'lang_obscured_title' => _MD_XOOPSPOLL_OBSCURED, ] ); @@ -176,14 +176,17 @@ } else { $optionId = Request::getInt('option_id', 0, 'POST'); } - if (!$pollObj->hasExpired()) { + if ($pollObj->hasExpired()) { + /* poll has expired so just show the results */ + $msg = _MD_XOOPSPOLL_SORRYEXPIRED; + } else { $msg = _MD_XOOPSPOLL_MUSTLOGIN; //@todo:: add $url to all redirects // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $pollId)); if ($pollObj->isAllowedToVote()) { $thisVoter = (!empty($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) ? $GLOBALS['xoopsUser']->getVar('uid') : null; - $votedThisPoll = $logHandler->hasVoted($pollId, xoops_getenv('REMOTE_ADDR'), $thisVoter); + $votedThisPoll = $logHandler->hasVoted($pollId, xoops_getenv('REMOTE_ADDR'), (int)$thisVoter); if (!$votedThisPoll) { /* user that hasn't voted before in this poll or module preferences allow it */ $voteTime = time(); @@ -202,14 +205,11 @@ } /* set anon user vote (and the time they voted) */ if (!$GLOBALS['xoopsUser'] instanceof \XoopsUser) { - Utility::setVoteCookie($pollId, $voteTime, 0); + Utility::setVoteCookie($pollId, (string)$voteTime, 0); } } else { $msg = _MD_XOOPSPOLL_CANNOTVOTE; } - } else { - /* poll has expired so just show the results */ - $msg = _MD_XOOPSPOLL_SORRYEXPIRED; } } else { $msg = _MD_XOOPSPOLL_ERROR_INVALID_POLLID; @@ -237,8 +237,8 @@ if ($pollObj->isAllowedToVote()) { $thisVoter = (!empty($GLOBALS['xoopsUser']) && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) ? $GLOBALS['xoopsUser']->getVar('uid') : null; - $canVote = $logHandler->hasVoted($pollId, xoops_getenv('REMOTE_ADDR'), $thisVoter) ? false : true; - $multiple = $pollObj->getVar('multiple') ? true : false; + $canVote = !$logHandler->hasVoted($pollId, xoops_getenv('REMOTE_ADDR'), $thisVoter); + $multiple = $pollObj->getVar('multiple'); $multiLimit = (int)$pollObj->getVar('multilimit'); if ($multiple && ($multiLimit > 0)) { $lang_multi = sprintf(_MD_XOOPSPOLL_MULTITEXT, $multiLimit); @@ -247,11 +247,11 @@ $GLOBALS['xoopsTpl']->assign( [ - 'voteCount' => $voteCount, - 'lang_vote' => _MD_XOOPSPOLL_VOTE, - 'lang_results' => _MD_XOOPSPOLL_RESULTS, - 'disp_votes' => $GLOBALS['xoopsModuleConfig']['disp_vote_nums'], - 'can_vote' => $canVote, + 'voteCount' => $voteCount, + 'lang_vote' => _MD_XOOPSPOLL_VOTE, + 'lang_results' => _MD_XOOPSPOLL_RESULTS, + 'disp_votes' => $GLOBALS['xoopsModuleConfig']['disp_vote_nums'], + 'can_vote' => $canVote, 'lang_multi' => $lang_multi, ] ); diff --git a/language/english/admin.php b/language/english/admin.php index d8e74a9..6d9af0c 100644 --- a/language/english/admin.php +++ b/language/english/admin.php @@ -1,9 +1,8 @@ -Disabled (No thumbnails available)"); -define('CO_' . $moduleDirNameUpper . '_' . 'GDON', "Enabled (Thumbsnails available)"); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGEINFO', 'Server status'); -define('CO_' . $moduleDirNameUpper . '_' . 'MAXPOSTSIZE', 'Max post size permitted (post_max_size directive in php.ini): '); -define('CO_' . $moduleDirNameUpper . '_' . 'MAXUPLOADSIZE', 'Max upload size permitted (upload_max_filesize directive in php.ini): '); -define('CO_' . $moduleDirNameUpper . '_' . 'MEMORYLIMIT', 'Memory limit (memory_limit directive in php.ini): '); -define('CO_' . $moduleDirNameUpper . '_' . 'METAVERSION', "Downloads meta version: "); -define('CO_' . $moduleDirNameUpper . '_' . 'OFF', "OFF"); -define('CO_' . $moduleDirNameUpper . '_' . 'ON', "ON"); -define('CO_' . $moduleDirNameUpper . '_' . 'SERVERPATH', 'Server path to XOOPS root: '); -define('CO_' . $moduleDirNameUpper . '_' . 'SERVERUPLOADSTATUS', 'Server uploads status: '); -define('CO_' . $moduleDirNameUpper . '_' . 'SPHPINI', "Information taken from PHP ini file:"); -define('CO_' . $moduleDirNameUpper . '_' . 'UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); - -define('CO_' . $moduleDirNameUpper . '_' . 'PRINT', "Print"); -define('CO_' . $moduleDirNameUpper . '_' . 'PDF', "Create PDF"); - -define('CO_' . $moduleDirNameUpper . '_' . 'UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); -define('CO_' . $moduleDirNameUpper . '_' . 'UPGRADEFAILED1', "Update failed - couldn't add new fields"); -define('CO_' . $moduleDirNameUpper . '_' . 'UPGRADEFAILED2', "Update failed - couldn't rename table '%s'"); -define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_COLUMN', 'Could not create column in database : %s'); -define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); -define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); -define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); - -define('CO_' . $moduleDirNameUpper . '_' . 'FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); +$moduleDirName = \basename(\dirname(__DIR__, 2)); +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); + +\define('CO_' . $moduleDirNameUpper . '_' . 'GDLIBSTATUS', 'GD library support: '); +\define('CO_' . $moduleDirNameUpper . '_' . 'GDLIBVERSION', 'GD Library version: '); +\define('CO_' . $moduleDirNameUpper . '_' . 'GDOFF', "Disabled (No thumbnails available)"); +\define('CO_' . $moduleDirNameUpper . '_' . 'GDON', "Enabled (Thumbsnails available)"); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGEINFO', 'Server status'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MAXPOSTSIZE', 'Max post size permitted (post_max_size directive in php.ini): '); +\define('CO_' . $moduleDirNameUpper . '_' . 'MAXUPLOADSIZE', 'Max upload size permitted (upload_max_filesize directive in php.ini): '); +\define('CO_' . $moduleDirNameUpper . '_' . 'MEMORYLIMIT', 'Memory limit (memory_limit directive in php.ini): '); +\define('CO_' . $moduleDirNameUpper . '_' . 'METAVERSION', "Downloads meta version: "); +\define('CO_' . $moduleDirNameUpper . '_' . 'OFF', "OFF"); +\define('CO_' . $moduleDirNameUpper . '_' . 'ON', "ON"); +\define('CO_' . $moduleDirNameUpper . '_' . 'SERVERPATH', 'Server path to XOOPS root: '); +\define('CO_' . $moduleDirNameUpper . '_' . 'SERVERUPLOADSTATUS', 'Server uploads status: '); +\define('CO_' . $moduleDirNameUpper . '_' . 'SPHPINI', "Information taken from PHP ini file:"); +\define('CO_' . $moduleDirNameUpper . '_' . 'UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); + +\define('CO_' . $moduleDirNameUpper . '_PRINT', "Print"); +\define('CO_' . $moduleDirNameUpper . '_PDF', "Create PDF"); + +\define('CO_' . $moduleDirNameUpper . '_' . 'UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); +\define('CO_' . $moduleDirNameUpper . '_' . 'UPGRADEFAILED1', "Update failed - couldn't add new fields"); +\define('CO_' . $moduleDirNameUpper . '_' . 'UPGRADEFAILED2', "Update failed - couldn't rename table '%s'"); +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_COLUMN', 'Could not create column in database : %s'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); // Error Msgs -define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); -define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_REMOVE', 'Could not delete %s'); -define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_NO_PLUGIN', 'Could not load plugin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_BAD_REMOVE', 'Could not delete %s'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_NO_PLUGIN', 'Could not load plugin'); //Help -define('CO_' . $moduleDirNameUpper . '_' . 'DIRNAME', basename(dirname(__DIR__, 2))); -define('CO_' . $moduleDirNameUpper . '_' . 'HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); -define('CO_' . $moduleDirNameUpper . '_' . 'BACK_2_ADMIN', 'Back to Administration of '); -define('CO_' . $moduleDirNameUpper . '_' . 'OVERVIEW', 'Overview'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRNAME', basename(dirname(__DIR__, 2))); +\define('CO_' . $moduleDirNameUpper . '_' . 'HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BACK_2_ADMIN', 'Back to Administration of '); +\define('CO_' . $moduleDirNameUpper . '_' . 'OVERVIEW', 'Overview'); -//define('CO_' . $moduleDirNameUpper . '_' . 'HELP_DIR', __DIR__); +//\define('CO_' . $moduleDirNameUpper . '_HELP_DIR', __DIR__); -//help multi-page -define('CO_' . $moduleDirNameUpper . '_' . 'DISCLAIMER', 'Disclaimer'); -define('CO_' . $moduleDirNameUpper . '_' . 'LICENSE', 'License'); -define('CO_' . $moduleDirNameUpper . '_' . 'SUPPORT', 'Support'); +//help multipage +\define('CO_' . $moduleDirNameUpper . '_' . 'DISCLAIMER', 'Disclaimer'); +\define('CO_' . $moduleDirNameUpper . '_' . 'LICENSE', 'License'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SUPPORT', 'Support'); //Sample Data -define('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA', 'Import Sample Data (will delete ALL current data)'); -define('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS', 'Sample Date uploaded successfully'); -define('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA', 'Export Tables to YAML'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', 'Show Sample Button?'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', 'If yes, the "Add Sample Data" button will be visible to the Admin. It is Yes as a default for first installation.'); -define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML'); -define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); -define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); -define('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK', 'Are you sure to Import Sample Data? (It will delete ALL current data)'); -define('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS', 'Hide the Import buttons)'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS', 'Show the Import buttons)'); -define('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM', 'Confirm'); +\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA', 'Import Sample Data (will delete ALL current data)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM', 'Are you sure to Import Sample Data? (It will delete ALL current data)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS', 'Sample Date imported successfully'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA', 'Export Tables to YAML'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS', 'Export Tables to YAML successfully'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA', 'Clear Sample Data'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK', 'The Sample Data has been cleared'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_CONFIRM', 'Are you sure to Clear Sample Data? (It will delete ALL current data)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success'); +\define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON', 'Show Sample Button?'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC', 'If yes, the "Add Sample Data" button will be visible to the Admin. It is Yes as a default for first installation.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS', 'Hide the Import buttons)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS', 'Show the Import buttons)'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM', 'Confirm'); //letter choice -define('CO_' . $moduleDirNameUpper . '_' . 'BROWSETOTOPIC', "Browse items alphabetically"); -define('CO_' . $moduleDirNameUpper . '_' . 'OTHER', 'Other'); -define('CO_' . $moduleDirNameUpper . '_' . 'ALL', 'All'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BROWSETOTOPIC', "Browse items alphabetically"); +\define('CO_' . $moduleDirNameUpper . '_' . 'OTHER', 'Other'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ALL', 'All'); // block defines -define('CO_' . $moduleDirNameUpper . '_' . 'ACCESSRIGHTS', 'Access Rights'); -define('CO_' . $moduleDirNameUpper . '_' . 'ACTION', 'Action'); -define('CO_' . $moduleDirNameUpper . '_' . 'ACTIVERIGHTS', 'Active Rights'); -define('CO_' . $moduleDirNameUpper . '_' . 'BADMIN', 'Block Administration'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLKDESC', 'Description'); -define('CO_' . $moduleDirNameUpper . '_' . 'CBCENTER', 'Center Middle'); -define('CO_' . $moduleDirNameUpper . '_' . 'CBLEFT', 'Center Left'); -define('CO_' . $moduleDirNameUpper . '_' . 'CBRIGHT', 'Center Right'); -define('CO_' . $moduleDirNameUpper . '_' . 'SBLEFT', 'Left'); -define('CO_' . $moduleDirNameUpper . '_' . 'SBRIGHT', 'Right'); -define('CO_' . $moduleDirNameUpper . '_' . 'SIDE', 'Alignment'); -define('CO_' . $moduleDirNameUpper . '_' . 'TITLE', 'Title'); -define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE', 'Visible'); -define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN', 'Visible In'); -define('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT', 'Weight'); - -define('CO_' . $moduleDirNameUpper . '_' . 'PERMISSIONS', 'Permissions'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS', 'Blocks Admin'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_DESC', 'Blocks/Group Admin'); - -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_MANAGMENT', 'Manage'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADDBLOCK', 'Add a new block'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK', 'Edit a block'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK', 'Clone a block'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ACCESSRIGHTS', 'Access Rights'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ACTION', 'Action'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ACTIVERIGHTS', 'Active Rights'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BADMIN', 'Block Administration'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLKDESC', 'Description'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CBCENTER', 'Center Middle'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CBLEFT', 'Center Left'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CBRIGHT', 'Center Right'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SBLEFT', 'Left'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SBRIGHT', 'Right'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SIDE', 'Alignment'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TITLE', 'Title'); +\define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE', 'Visible'); +\define('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN', 'Visible In'); +\define('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT', 'Weight'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMISSIONS', 'Permissions'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_DESC', 'Blocks/Group Admin'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_MANAGMENT', 'Manage'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADDBLOCK', 'Add a new block'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK', 'Edit a block'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK', 'Clone a block'); //myblocksadmin -define('CO_' . $moduleDirNameUpper . '_' . 'AGDS', 'Admin Groups'); -define('CO_' . $moduleDirNameUpper . '_' . 'BCACHETIME', 'Cache Time'); -define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADMIN', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'AGDS', 'Admin Groups'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BCACHETIME', 'Cache Time'); +\define('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_ADMIN', 'Blocks Admin'); +\define('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS', 'Update successful'); //Template Admin -define('CO_' . $moduleDirNameUpper . '_' . 'TPLSETS', 'Template Management'); -define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE', 'Generate'); -define('CO_' . $moduleDirNameUpper . '_' . 'FILENAME', 'File Name'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TPLSETS', 'Template Management'); +\define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE', 'Generate'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILENAME', 'File Name'); //Menu -define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); -define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); -define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); -define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); -define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK', 'Feedback'); -define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK', 'Database migrated to current schema.'); -define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING', 'Warning! This is intended for developers only. Confirm write schema file from current database.'); -define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK', 'Current schema file written'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE', 'Migrate'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_YES', 'Folder "%s" exist'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FOLDER_NO', 'Folder "%s" does not exist. Create the specified folder with CHMOD 777.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS', 'Show Development Tools Button?'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK', 'Feedback'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK', 'Database migrated to current schema.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING', 'Warning! This is intended for developers only. Confirm write schema file from current database.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK', 'Current schema file written'); //Latest Version Check -define('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION', 'New Version: '); +\define('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION', 'New Version: '); //DirectoryChecker -define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); -define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); -define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); -define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEDIR', 'Create it'); -define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); -define('CO_' . $moduleDirNameUpper . '_' . 'DIRCREATED', 'The directory has been created'); -define('CO_' . $moduleDirNameUpper . '_' . 'DIRNOTCREATED', 'The directory cannot be created'); -define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); -define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); +\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); +\define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); +\define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); +\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEDIR', 'Create it'); +\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRCREATED', 'The directory has been created'); +\define('CO_' . $moduleDirNameUpper . '_' . 'DIRNOTCREATED', 'The directory cannot be created'); +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); +\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); //FileChecker -//define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); -//define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); -//define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); -//define('CO_' . $moduleDirNameUpper . '_' . 'COPYTHEFILE', 'Copy it'); -//define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEFILE', 'Create it'); -//define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); +//\define('CO_' . $moduleDirNameUpper . '_' . 'AVAILABLE', "Available"); +//\define('CO_' . $moduleDirNameUpper . '_' . 'NOTAVAILABLE', "Not available"); +//\define('CO_' . $moduleDirNameUpper . '_' . 'NOTWRITABLE', "Should have permission ( %d ), but it has ( %d )"); +//\define('CO_' . $moduleDirNameUpper . '_' . 'COPYTHEFILE', 'Copy it'); +//\define('CO_' . $moduleDirNameUpper . '_' . 'CREATETHEFILE', 'Create it'); +//\define('CO_' . $moduleDirNameUpper . '_' . 'SETMPERM', 'Set the permission'); -define('CO_' . $moduleDirNameUpper . '_' . 'FILECOPIED', 'The file has been copied'); -define('CO_' . $moduleDirNameUpper . '_' . 'FILENOTCOPIED', 'The file cannot be copied'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILECOPIED', 'The file has been copied'); +\define('CO_' . $moduleDirNameUpper . '_' . 'FILENOTCOPIED', 'The file cannot be copied'); -//define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); -//define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); +//\define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set'); +//\define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set'); //image config -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', 'Image Display Height'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'Display height for image'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', '--- EXTERNAL Image configuration --- '); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); - -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE', 'Image File Size (in Bytes)'); -define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE_DSC','The maximum file size of the image file (in Bytes)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_EXT_IMAGE', 'EXTERNAL Image configuration'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_START', ':: '); +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_END', ' :: '); +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_DESC_START', ''); +\define('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_DESC_END', ' '); + +\define('CO_' . $moduleDirNameUpper . '_' . 'PREFERENCE_BREAK_CONFIG_IMAGE', constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_START') . constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_EXT_IMAGE') . constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIG_STYLING_END')); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT', 'Image Display Height'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC', 'Display height for image'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG', '--- EXTERNAL Image configuration --- '); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', ''); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE', 'Image File Size (in Bytes)'); +\define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_FILE_SIZE_DSC','The maximum file size of the image file (in Bytes)'); + +//Module Stats +\define('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY', 'Module Statistics'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_CATEGORIES', 'Categories:'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_ITEMS', 'Items'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_OFFLINE', 'Offline'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_PUBLISHED', 'Published'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_REJECTED', 'Rejected'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_SUBMITTED', 'Submitted'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR403', 'You are not allowed to view this page!'); //Preferences -define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field'); -define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field'); +\define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields'); + +\define('CO_' . $moduleDirNameUpper . '_' . 'DELETE_BLOCK_CONFIRM', 'Are you sure to delete this Block?'); + +//Cloning +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE', 'Clone'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_DSC', 'Cloning a module has never been this easy! Just type in the name you want for it and hit submit button!'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_TITLE', 'Clone %s'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME', 'Choose a name for the new module'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME_DSC', 'Do not use special characters!
    Do not choose an existing module dirname or database table name!'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_INVALIDNAME', 'ERROR: Invalid module name, please try another one!'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_EXISTS', 'ERROR: Module name already taken, please try another one!'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_CONGRAT', 'Congratulations! %s was sucessfully created!
    You may want to make changes in language files.'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_IMAGEFAIL', 'Attention, we failed creating the new module logo. Please consider modifying assets/images/logo_module.png manually!'); +\define('CO_' . $moduleDirNameUpper . '_' . 'CLONE_FAIL', "Sorry, we failed in creating the new clone. Maybe you need to temporally set write permissions (CHMOD 777) to 'modules' folder and try again."); + +//JSON-LD generation of www.schema.org +\define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE_JSONLD', 'Generate Schema Markup through JSON LD'); +\define('CO_' . $moduleDirNameUpper . '_' . 'GENERATE_JSONLD_DESC', 'Mark up your module with structured data to help search engines better understand the content of your web page'); + +//Repository not found +\define('CO_' . $moduleDirNameUpper . '_' . 'REPO_NOT_FOUND', 'Repository Not Found: '); +//Release not found +\define('CO_' . $moduleDirNameUpper . '_' . 'NO_REL_FOUND', 'Released Version Not Found: '); +//rename upload folder on uninstall +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_FOLDER_RENAME_FAILED', 'Could not rename upload folder, please rename manually'); + +//TCPDF +\define('CO_' . $moduleDirNameUpper . '_' . 'ERROR_NO_PDF', 'TCPDF for XOOPS is not installed in /class/libraries/vendor/tecnickcom/tcpdf/
    Please read the /docs/readme.txt or click on the Help tab to learn how to get it!'); -//Module Stats -define('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY', 'Module Statistics'); -define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_CATEGORIES', 'Categories:'); -define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_ITEMS', 'Items'); -define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_OFFLINE', 'Offline'); -define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_PUBLISHED', 'Published'); -define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_REJECTED', 'Rejected'); -define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_SUBMITTED', 'Submitted'); diff --git a/language/english/help/disclaimer.tpl b/language/english/help/disclaimer.tpl index 20e979f..7386bde 100644 --- a/language/english/help/disclaimer.tpl +++ b/language/english/help/disclaimer.tpl @@ -3,7 +3,7 @@

    DISCLAIMER


    -

    Software downloaded from the XOOPS web site is provided 'as is' without warranty +

    Software downloaded from the XOOPS website is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied warranties of fitness for a purpose, or the warranty of non-infringement. Without limiting the foregoing, XOOPS Projects team makes no warranty that:

    @@ -15,21 +15,21 @@ accurate or reliable
  • the quality of the software will meet your expectations any errors in the - software obtained from XOOPS web site will be corrected. + software obtained from XOOPS website will be corrected.

  • -

    Software and its documentation made available on the XOOPS web site:

    +

    Software and its documentation made available on the XOOPS website:


    1. could include technical or other mistakes, inaccuracies or typographical errors. XOOPS may make changes to the software or documentation made available - on its web site. + on its website.
    2. may be out of date, and XOOPS makes no commitment to update such materials.
    3. XOOPS assumes no responsibility for errors or omissions in the software - or documentation available from its web site. + or documentation available from its website.


    In no event shall XOOPS team be liable to you or any third parties for @@ -43,6 +43,6 @@ and risk and with agreement that you will be solely responsible for any damage to your computer system or loss of data that results from such activities. No advice or information, whether oral or written, obtained by you from XOOPS or from XOOPS - web site shall create any warranty for the software

    + website shall create any warranty for the software

    diff --git a/language/english/help/help.html b/language/english/help/help.html index 7d7dcd5..50a30cd 100644 --- a/language/english/help/help.html +++ b/language/english/help/help.html @@ -2,8 +2,8 @@

    Help: XOOPS Poll - Back to the Administration of XOOPS Poll + Back to the Administration of XOOPS Poll

    DESCRIPTION

    @@ -20,11 +20,11 @@

    INSTALL/UNINSTALL

    extract the xoopspoll folder into the ../modules directory. Install the module through Admin -> System Module -> Modules.

    Detailed instructions on installing modules are available in the - XOOPS Operations Manual

    + XOOPS Operations Manual

    Additional integration with both the Marquee module and the SmartClone XOOPS modules are included in the extras folder. Copy these plugins to the corresponding folder in those modules to enable support for the XOOPS poll - module. Additionally a patch has been created for the forum module (newbb) + module. Additionally, a patch has been created for the forum module (newbb) to support this version of XOOPS poll. Replace the existing forum module files with the files found in the ./extras/newbb folder.

    It is recommended that you delete the ./xoopspoll/extras and @@ -47,7 +47,7 @@

    OPERATING INSTRUCTIONS

  • the Polls module and
  • the Polls block so that they can see it and vote. Detailed instructions on configuring the access rights for user groups are - available in the XOOPS Operations + available in the XOOPS Operations Manual
@@ -93,9 +93,9 @@
User Voting

TUTORIAL

- Tutorial has been started, but we might need your help! Please check out the status of the tutorial here . + Tutorial has been started, but we might need your help! Please check out the status of the tutorial here .

To contribute to this Tutorial, please fork it on GitHub. -
This document describes our Documentation Process and it will help you to understand how to contribute. +
This document describes our Documentation Process and it will help you to understand how to contribute.

There are more XOOPS Tutorials, so check them out in our XOOPS Tutorial Repository on GitBook.

@@ -105,7 +105,7 @@

TRANSLATIONS

Translations are on Transifex and in our XOOPS Languages Repository on GitHub.

SUPPORT

-

If you have questions about this module and need help, you can visit our Support Forums on XOOPS Website

+

If you have questions about this module and need help, you can visit our Support Forums on XOOPS Website

DEVELOPMENT

This module is Open Source and we would love your help in making it better! You can fork this module on GitHub

diff --git a/language/english/help/help.tpl b/language/english/help/help.tpl index 2ce642c..9a16a86 100644 --- a/language/english/help/help.tpl +++ b/language/english/help/help.tpl @@ -2,7 +2,7 @@

Help: XOOPS Poll - Back to the Administration of XOOPS Poll

diff --git a/language/english/help/helpheader.tpl b/language/english/help/helpheader.tpl index c93f87c..1997e9a 100644 --- a/language/english/help/helpheader.tpl +++ b/language/english/help/helpheader.tpl @@ -1,6 +1,6 @@

Help: <{$smarty.const._MI_XOOPSPOLL_NAME}> - <{$smarty.const._MI_XOOPSPOLL_BACK_2_ADMIN}> <{$smarty.const._MI_XOOPSPOLL_NAME}> + <{$smarty.const._MI_XOOPSPOLL_BACK_2_ADMIN}> <{$smarty.const._MI_XOOPSPOLL_NAME}>

diff --git a/language/english/help/index.html b/language/english/help/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/language/english/help/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/language/english/help/index.php b/language/english/help/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/language/english/help/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/language/english/index.php b/language/english/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/language/english/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/language/english/mail_template/index.php b/language/english/mail_template/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/language/english/mail_template/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/language/index.php b/language/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/language/index.php @@ -0,0 +1,3 @@ +getHandler('Poll'); $pollObj = $pollHandler->get($pollId); -if (!empty($pollObj) && ($pollObj instanceof Poll)) { +if (($pollObj instanceof Poll)) { /* make sure the poll has started */ if ($pollObj->getVar('start_time') > time()) { redirect_header('index.php', Constants::REDIRECT_DELAY_NONE); @@ -94,10 +94,10 @@ $GLOBALS['xoopsTpl']->assign( [ - 'visible_msg' => $visibleMsg, - 'disp_votes' => $GLOBALS['xoopsModuleConfig']['disp_vote_nums'], - 'back_link_icon' => \Xmf\Module\Admin::iconUrl('', 16) . '/back.png', - 'back_link' => $GLOBALS['xoops']->url('modules/xoopspoll/index.php'), + 'visible_msg' => $visibleMsg, + 'disp_votes' => $GLOBALS['xoopsModuleConfig']['disp_vote_nums'], + 'back_link_icon' => Admin::iconUrl('', '16') . '/back.png', + 'back_link' => $GLOBALS['xoops']->url('modules/xoopspoll/index.php'), 'back_text' => _BACK, ] ); diff --git a/preloads/autoloader.php b/preloads/autoloader.php index b0c8e17..f8de47d 100644 --- a/preloads/autoloader.php +++ b/preloads/autoloader.php @@ -1,15 +1,15 @@ - **/ -use XoopsModules\Xoopspoll; +use XoopsModules\Xoopspoll\Helper; /** * Class XoopspollCorePreload @@ -42,24 +41,23 @@ class XoopspollCorePreload extends \XoopsPreloadItem { // to add PSR-4 autoloader - /** - * @param $args + * @param array $args */ - public static function eventCoreIncludeCommonEnd($args) + public static function eventCoreIncludeCommonEnd(array $args): void { require __DIR__ . '/autoloader.php'; } /** * plugin class for Xoops preload for index page start - * @param $args + * @param array $args */ - public static function eventCoreIndexStart($args) + public static function eventCoreIndexStart(array $args): void { // check once per user session if expired poll email has been sent if (empty($_SESSION['pollChecked'])) { - $pollHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Poll'); + $pollHandler = Helper::getInstance()->getHandler('Poll'); $pollHandler->mailResults(); //send the results of any polls that have ended unset($pollHandler); $_SESSION['pollChecked'] = 1; diff --git a/preloads/index.html b/preloads/index.html index 2c5cdd3..990cbd6 100644 --- a/preloads/index.html +++ b/preloads/index.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/sql/index.html b/sql/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/sql/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/sql/index.php b/sql/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/sql/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/templates/admin/index.php b/templates/admin/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/templates/admin/index.php @@ -0,0 +1,3 @@ +<{$smarty.const._AM_XOOPSPOLL_VOTES}> <{$smarty.const._AM_XOOPSPOLL_START_TIME}> <{$smarty.const._AM_XOOPSPOLL_EXPIRATION}> - <{$smarty.const._AM_XOOPSPOLL_ACTIONS}> + <{$smarty.const._AM_XOOPSPOLL_ACTIONS}> @@ -53,6 +53,8 @@ <{$pollItem.votes}> <{$pollItem.xuStartFormattedTime}> <{$pollItem.end}> + + <{html_image file=$pollItem.buttons.edit.file href=$pollItem.buttons.edit.href alt=$pollItem.buttons.edit.alt title=$pollItem.buttons.edit.alt}> diff --git a/templates/blocks/index.html b/templates/blocks/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/templates/blocks/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/blocks/index.php b/templates/blocks/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/templates/blocks/index.php @@ -0,0 +1,3 @@ +/modules/xoopspoll/pollresults.php?poll_id=<{$poll.id}>'><{$block.comments}> <{$block.langComment}> <{elseif ($block.comments > 1)}> <{$block.comments}> <{$block.langComments}> - <{else}> + <{elseif isset($poll)}> <{$block.langComments}> ? <{/if}> diff --git a/templates/index.html b/templates/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/templates/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/index.php b/templates/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/templates/index.php @@ -0,0 +1,3 @@ +
- <{if $comment_mode == "flat"}> + <{if $comment_mode|default:'' == "flat"}> <{include file="db:system_comments_flat.tpl"}> - <{elseif $comment_mode == "thread"}> + <{elseif $comment_mode|default:'' == "thread"}> <{include file="db:system_comments_thread.tpl"}> - <{elseif $comment_mode == "nest"}> + <{elseif $comment_mode|default:'' == "nest"}> <{include file="db:system_comments_nest.tpl"}> <{/if}> diff --git a/templates/xoopspoll_view.tpl b/templates/xoopspoll_view.tpl index 30777a7..31019e4 100644 --- a/templates/xoopspoll_view.tpl +++ b/templates/xoopspoll_view.tpl @@ -20,7 +20,7 @@ <{/foreach}> - <{if "" != $lang_multi}> + <{if "" != $lang_multi|default:''}> <{$lang_multi}> @@ -31,7 +31,7 @@ <{if $can_vote}>   <{/if}> - <{if ($voteCount > 0)}> + <{if ($voteCount|default:0 > 0)}> <{/if}> diff --git a/test/index.html b/test/index.html deleted file mode 100644 index 2c5cdd3..0000000 --- a/test/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/index.php b/test/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/test/index.php @@ -0,0 +1,3 @@ + - + - + x258Suite diff --git a/testdata/english/index.html b/testdata/english/index.html deleted file mode 100644 index 74b6f45..0000000 --- a/testdata/english/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/testdata/english/index.php b/testdata/english/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/testdata/english/index.php @@ -0,0 +1,3 @@ +history.go(-1); diff --git a/testdata/images/index.php b/testdata/images/index.php new file mode 100644 index 0000000..b295ab9 --- /dev/null +++ b/testdata/images/index.php @@ -0,0 +1,3 @@ +history.go(-1); \ No newline at end of file diff --git a/testdata/index.php b/testdata/index.php index bc0ca49..6f1cb00 100644 --- a/testdata/index.php +++ b/testdata/index.php @@ -1,4 +1,5 @@ - 1, 'op' => 'load'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); + xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); xoops_cp_footer(); } break; case 'save': saveSampleData(); break; + case 'clear': + if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) { + if (!$GLOBALS['xoopsSecurity']->check()) { + redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); + } + clearSampleData(); + } else { + xoops_cp_header(); + xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); + xoops_cp_footer(); + } + break; } // XMF TableLoad for SAMPLE data -function loadSampleData() +function loadSampleData(): void { global $xoopsConfig; - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(__DIR__)); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); $utility = new Utility(); - $configurator = new Common\Configurator(); + $configurator = new Configurator(); $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); @@ -71,36 +88,36 @@ function loadSampleData() // load module tables foreach ($tables as $table) { - $tabledata = \Xmf\Yaml::readWrapped($language . $table . '.yml'); - \Xmf\Database\TableLoad::truncateTable($table); - \Xmf\Database\TableLoad::loadTableFromArray($table, $tabledata); + $tabledata = Yaml::readWrapped($language . $table . '.yml'); + TableLoad::truncateTable($table); + TableLoad::loadTableFromArray($table, $tabledata); } // load permissions $table = 'group_permission'; - $tabledata = \Xmf\Yaml::readWrapped($language . $table . '.yml'); + $tabledata = Yaml::readWrapped($language . $table . '.yml'); $mid = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getVar('mid'); loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid); // --- COPY test folder files --------------- if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders) > 0) { - // $file = dirname(__DIR__) . '/testdata/images/'; + // $file = \dirname(__DIR__) . '/testdata/images/'; foreach (array_keys($configurator->copyTestFolders) as $i) { $src = $configurator->copyTestFolders[$i][0]; $dest = $configurator->copyTestFolders[$i][1]; $utility::rcopy($src, $dest); } } - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); + \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS')); } -function saveSampleData() +function saveSampleData(): void { global $xoopsConfig; - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); - - $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); + $moduleDirName = \basename(\dirname(__DIR__)); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + $helper = Helper::getInstance(); + $tables = $helper->getModule()->getInfo('tables'); $languageFolder = __DIR__ . '/' . $xoopsConfig['language']; if (!file_exists($languageFolder . '/')) { @@ -111,23 +128,23 @@ function saveSampleData() // save module tables foreach ($tables as $table) { - \Xmf\Database\TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); + TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); } // save permissions $criteria = new \CriteriaCompo(); - $criteria->add(new \Criteria('gperm_modid', \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getVar('mid'))); + $criteria->add(new \Criteria('gperm_modid', $helper->getModule()->getVar('mid'))); $skipColumns[] = 'gperm_id'; - \Xmf\Database\TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns); + TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns); unset($criteria); - redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS')); + \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS')); } -function exportSchema() +function exportSchema(): void { - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = mb_strtoupper($moduleDirName); + $moduleDirName = \basename(\dirname(__DIR__)); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); try { // TODO set exportSchema @@ -143,16 +160,16 @@ function exportSchema() /** * loadTableFromArrayWithReplace * - * @param string $table value with should be used insead of original value of $search + * @param string $table value which should be used instead of original value of $search * - * @param array $data array of rows to insert + * @param array $data array of rows to insert * Each element of the outer array represents a single table row. * Each row is an associative array in 'column' => 'value' format. * @param string $search name of column for which the value should be replaced * @param $replace * @return int number of rows inserted */ -function loadTableFromArrayWithReplace($table, $data, $search, $replace) +function loadTableFromArrayWithReplace(string $table, array $data, string $search, $replace): int { /** @var \XoopsMySQLDatabase $db */ $db = \XoopsDatabaseFactory::getDatabaseConnection(); @@ -194,3 +211,18 @@ function loadTableFromArrayWithReplace($table, $data, $search, $replace) return $count; } + +function clearSampleData(): void +{ + $moduleDirName = \basename(\dirname(__DIR__)); + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); + $helper = Helper::getInstance(); + // Load language files + $helper->loadLanguage('common'); + $tables = $helper->getModule()->getInfo('tables'); + // truncate module tables + foreach ($tables as $table) { + \Xmf\Database\TableLoad::truncateTable($table); + } + redirect_header($helper->url('admin/index.php'), 1, constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK')); +} diff --git a/xoops_version.php b/xoops_version.php index d793b86..ae970b7 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -1,4 +1,4 @@ - 2.01, - 'module_status' => 'Beta 1', - 'release_date' => '2020/07/21', + 'version' => '2.1.0', + 'module_status' => 'Beta 2', + 'release_date' => '2023/04/20', 'name' => _MI_XOOPSPOLL_NAME, 'description' => _MI_XOOPSPOLL_DESC, 'official' => 0, //1 indicates official XOOPS module supported by XOOPS Dev Team, 0 means 3rd party supported @@ -80,8 +78,8 @@ 'module_website_url' => 'www.xoops.org', 'module_website_name' => 'XOOPS Project', // ------------------- Min Requirements ------------------- - 'min_php' => '7.1', - 'min_xoops' => '2.5.10', + 'min_php' => '7.4', + 'min_xoops' => '2.5.11', 'min_admin' => '1.2', 'min_db' => ['mysql' => '5.5'], // ------------------- Admin Menu ------------------- @@ -106,13 +104,13 @@ 'hasSearch' => 1, 'search' => [ 'file' => 'include/search.php', - 'func' => 'pedigree_search', + 'func' => 'xoopspoll_search', ], // ------------------- Comments ------------------------- 'hasComments' => 1, 'comments' => [ - 'pageName' => 'pollresults.php', - 'itemName' => 'poll_id', + 'pageName' => 'pollresults.php', + 'itemName' => 'poll_id', ], // ------------------- Mysql ----------------------------- 'sqlfile' => ['mysql' => 'sql/mysql.sql'], @@ -125,7 +123,6 @@ ]; // ------------------- Templates ------------------- // - $modversion['templates'] = [ ['file' => 'xoopspoll_index.tpl', 'description' => _MI_XOOPSPOLL_INDEX_DSC], ['file' => 'xoopspoll_view.tpl', 'description' => _MI_XOOPSPOLL_VIEW_DSC], @@ -145,15 +142,6 @@ ['name' => _MI_XOOPSPOLL_SUPPORT, 'link' => 'page=support'], ]; - -/** - * Search definitions - * 1 = yes, module has search | 0 = no - */ -$modversion['hasSearch'] = 1; -$modversion['search']['file'] = 'include/search.php'; -$modversion['search']['func'] = 'xoopspoll_search'; - /**#@+ * Block template description */ @@ -277,4 +265,3 @@ 'valuetype' => 'int', 'default' => 0, ]; -