|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Xoopspoll uninstall functions.php |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright:: {@link https://xoops.org/ XOOPS Project} |
|
16
|
|
|
* @license :: {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2.0 or later} |
|
17
|
|
|
* @since :: 1.40 |
|
18
|
|
|
* @author :: zyspec <[email protected]> |
|
19
|
|
|
* @param XoopsModule $module |
|
20
|
|
|
* @return bool |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
use XoopsModules\Newbb; |
|
24
|
|
|
use XoopsModules\Xoopspoll\{ |
|
25
|
|
|
Utility |
|
26
|
|
|
}; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param \XoopsModule $module |
|
30
|
|
|
* @return bool |
|
31
|
|
|
*/ |
|
32
|
|
|
function xoops_module_pre_uninstall_xoopspoll(\XoopsModule $module): bool |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
/* make sure that any polls associated with xoopspoll are cleared from newbb */ |
|
35
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
36
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
37
|
|
|
$newbbModule = $moduleHandler->getByDirname('newbb'); |
|
38
|
|
|
$success = true; |
|
39
|
|
|
if (is_object($newbbModule) && $newbbModule->getVar('isactive')) { |
|
40
|
|
|
/** @var Newbb\TopicHandler $topicHandler */ |
|
41
|
|
|
$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
42
|
|
|
$criteria = new \Criteria('topic_haspoll', 0, '>'); |
|
43
|
|
|
$s1 = $topicHandler->updateAll('poll_id', 0, $criteria); // clear any polls associated with forum topic |
|
44
|
|
|
$s2 = $topicHandler->updateAll('topic_haspoll', 0, $criteria); // clear haspoll indicator in forum |
|
45
|
|
|
$success = $s1 && $s2; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
return $success; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param XoopsModule $module |
|
53
|
|
|
* @return bool |
|
54
|
|
|
*/ |
|
55
|
|
|
function xoops_module_uninstall_xoopspoll(\XoopsModule $module): bool |
|
|
|
|
|
|
56
|
|
|
{ |
|
57
|
|
|
/* clear the voted cookie(s) for the admin user's machine when module is uninstalled */ |
|
58
|
|
|
$success = Utility::setVoteCookie('', '', time() - 3600); |
|
59
|
|
|
|
|
60
|
|
|
return $success; |
|
61
|
|
|
} |
|
62
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.