Issues (584)

include/comment_functions.php (2 issues)

Labels
Severity
1
<?php
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
 * wgGitHub module for xoops
14
 *
15
 * @copyright      2020 XOOPS Project (https://xooops.org)
16
 * @license        GPL 2.0 or later
17
 * @package        wggithub
18
 * @since          1.0
19
 * @min_xoops      2.5.10
20
 * @author         TDM XOOPS - Email:<[email protected]> - Website:<https://wedega.com>
21
 */
22
23
/**
24
 * CommentsUpdate
25
 *
26
 * @param mixed  $itemId
27
 * @param mixed  $itemNumb
28
 * @return bool
29
 */
30
function wggithubCommentsUpdate($itemId, $itemNumb)
31
{
32
    // Get instance of module
33
    $helper = \XoopsModules\Wggithub\Helper::getInstance();
34
    $repositoriesHandler = $helper->getHandler('Repositories');
35
    $repoId = (int)$itemId;
36
    $repositoriesObj = $repositoriesHandler->get($repoId);
37
    $repositoriesObj->setVar('repo_comments', (int)$itemNumb);
38
    if ($repositoriesHandler->insert($repositoriesObj)) {
39
        return true;
40
    }
41
    return false;
42
}
43
44
/**
45
 * CommentsApprove
46
 *
47
 * @param mixed $comment
48
 * @return bool
49
 */
50
function wggithubCommentsApprove($comment)
51
{
52
    // Notification event
53
    // Get instance of module
54
    $helper = \XoopsModules\Wggithub\Helper::getInstance();
55
    $repositoriesHandler = $helper->getHandler('Repositories');
56
    $repoId = $comment->getVar('com_itemid');
57
    $repositoriesObj = $repositoriesHandler->get($repoId);
58
    $repoName = $repositoriesObj->getVar('repo_name');
59
60
    $tags = [];
61
    $tags['ITEM_NAME'] = $repoName;
62
    $tags['ITEM_URL']  = \XOOPS_URL . '/modules/wggithub/repositories.php?op=show&repo_id=' . $repoId;
0 ignored issues
show
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
63
    $notificationHandler = \xoops_getHandler('notification');
0 ignored issues
show
The function xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
    $notificationHandler = /** @scrutinizer ignore-call */ \xoops_getHandler('notification');
Loading history...
64
    // Event modify notification
65
    $notificationHandler->triggerEvent('global', 0, 'global_comment', $tags);
66
    $notificationHandler->triggerEvent('repositories', $repoId, 'repository_comment', $tags);
67
    return true;
68
69
}
70