Passed
Push — master ( 077fbd...836ec9 )
by Michael
04:09
created

extcalLastVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use XoopsModules\Extcal;
4
5
require_once __DIR__ . '/admin_header.php';
6
require_once dirname(dirname(dirname(__DIR__))) . '/class/xoopsformloader.php';
7
8
function extcalLastVersion()
9
{
10
    //return @file_get_contents("http://www.zoullou.net/extcal.version");  //the Website is not longer working
11
}
12
13
/**
14
 * @return bool
15
 */
16
function isUpToDate()
17
{
18
    $version = extcalLastVersion();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $version is correct as extcalLastVersion() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
19
20
    return $GLOBALS['xoopsModule']->getVar('version') >= $version;
21
}
22
23
/** @var Extcal\Helper $helper */
24
$helper = Extcal\Helper::getInstance();
25
26
$op  = \Xmf\Request::getCmd('op', 'default');
27
$fct = \Xmf\Request::getString('fct', 'default', 'GET');
28
29
switch ($op) {
30
    case 'notification':
31
        switch ($fct) {
32
            case 'send':
33
                if (!$GLOBALS['xoopsSecurity']->check()) {
34
                    redirect_header('index.php', 3, _NOPERM . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
35
                }
36
                xoops_cp_header();
37
                adminMenu(1);
0 ignored issues
show
Bug introduced by
The function adminMenu 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

37
                /** @scrutinizer ignore-call */ 
38
                adminMenu(1);
Loading history...
38
39
                $myts        = \MyTextSanitizer::getInstance();
40
                $xoopsMailer = xoops_getMailer();
41
                //                $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
42
                //                $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
43
                //                $eventMemberHandler = xoops_getModuleHandler(_EXTCAL_CLS_MEMBER, _EXTCAL_MODULE);
44
                $extcalTime   = Extcal\Time::getHandler();
45
                $extcalConfig = Extcal\Config::getHandler();
46
47
                $event = $eventHandler->getEvent($_POST['event_id'], $xoopsUser, true);
48
                $cat   = $categoryHandler->getCat($event->getVar('cat_id'), $xoopsUser, 'all');
49
50
                $xoopsMailer->setToUsers($eventMemberHandler->getMembers($_POST['event_id']));
51
                $xoopsMailer->setFromName($myts->oopsStripSlashesGPC($_POST['mail_fromname']));
52
                $xoopsMailer->setFromEmail($myts->oopsStripSlashesGPC($_POST['mail_fromemail']));
53
                $xoopsMailer->setSubject($myts->oopsStripSlashesGPC($_POST['mail_subject']));
54
                $xoopsMailer->setBody($myts->oopsStripSlashesGPC($_POST['mail_body']));
55
                if (in_array('mail', $_POST['mail_send_to'])) {
56
                    $xoopsMailer->useMail();
57
                }
58
                if (empty($_POST['mail_inactive']) && in_array('pm', $_POST['mail_send_to'])) {
59
                    $xoopsMailer->usePM();
60
                }
61
                $tag = [
62
                    'EV_CAT'   => $cat->getVar('cat_name'),
63
                    'EV_TITLE' => $event->getVar('event_title'),
64
                    'EV_START' => $extcalTime->getFormatedDate($helper->getConfig('date_long'), $event->getVar('event_start')),
65
                    'EV_END'   => $extcalTime->getFormatedDate($helper->getConfig('date_long'), $event->getVar('event_end')),
66
                    'EV_LINK'  => XOOPS_URL . '/modules/extcal/event.php?event=' . $event->getVar('event_id'),
67
                ];
68
                $xoopsMailer->assign($tag);
69
                $xoopsMailer->send(true);
70
                echo $xoopsMailer->getSuccess();
71
                echo $xoopsMailer->getErrors();
72
73
                xoops_cp_footer();
74
75
                break;
76
            case 'default':
77
            default:
78
                xoops_cp_header();
79
                $fromemail      = !empty($xoopsConfig['adminmail']) ? $xoopsConfig['adminmail'] : $xoopsUser->getVar('email', 'E');
80
                $subjectCaption = _AM_EXTCAL_SUBJECT . "<br><br><span style='font-size:x-small;font-weight:bold;'>" . _AM_EXTCAL_USEFUL_TAGS . "</span><br><span style='font-size:x-small;font-weight:normal;'>" . _AM_EXTCAL_MAILTAGS6 . '<br>' . _AM_EXTCAL_MAILTAGS2 . '</span>&nbsp;&nbsp;&nbsp;';
81
                $bodyCaption    = _AM_EXTCAL_BODY
82
                                  . "<br><br><span style='font-size:x-small;font-weight:bold;'>"
83
                                  . _AM_EXTCAL_USEFUL_TAGS
84
                                  . "</span><br><span style='font-size:x-small;font-weight:normal;'>"
85
                                  . _AM_EXTCAL_MAILTAGS1
86
                                  . '<br>'
87
                                  . _AM_EXTCAL_MAILTAGS2
88
                                  . '<br>'
89
                                  . _AM_EXTCAL_MAILTAGS3
90
                                  . '<br>'
91
                                  . _AM_EXTCAL_MAILTAGS4
92
                                  . '<br>'
93
                                  . _AM_EXTCAL_MAILTAGS5
94
                                  . '<br>'
95
                                  . _AM_EXTCAL_MAILTAGS6
96
                                  . '<br>'
97
                                  . _AM_EXTCAL_MAILTAGS7
98
                                  . '<br>'
99
                                  . _AM_EXTCAL_MAILTAGS8
100
                                  . '<br>'
101
                                  . _AM_EXTCAL_MAILTAGS9
102
                                  . '</span>&nbsp;&nbsp;&nbsp;';
103
                $toCheckBbox    = new \XoopsFormCheckBox(_AM_EXTCAL_SEND_TO, 'mail_send_to', 'mail');
104
                $toCheckBox->addOption('mail', _AM_EXTCAL_EMAIL);
105
                $toCheckBox->addOption('pm', _AM_EXTCAL_PM);
106
107
                echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTCAL_APPROVED_EVENT . '</legend>';
108
                echo '<fieldset><legend style="font-weight:bold; color:#0A3760;">' . _AM_EXTCAL_INFORMATION . '</legend>';
109
                echo _AM_EXTCAL_INFO_SEND_NOTIF;
110
                echo '</fieldset><br>';
111
                $form = new \XoopsThemeForm(_AM_EXTCAL_SEND_NOTIFICATION, 'mailusers', 'index.php?op=notification&amp;fct=send', 'post', true);
112
                $form->addElement(new \XoopsFormText(_AM_EXTCAL_FROM_NAME, 'mail_fromname', 30, 255, $xoopsConfig['sitename']), true);
113
                $form->addElement(new \XoopsFormText(_AM_EXTCAL_FROM_EMAIL, 'mail_fromemail', 30, 255, $fromemail), true);
114
                $form->addElement(new \XoopsFormText($subjectCaption, 'mail_subject', 50, 255, _AM_EXTCAL_SEND_NOTIFICATION_SUBJECT), true);
115
                $form->addElement(new \XoopsFormTextArea($bodyCaption, 'mail_body', _AM_EXTCAL_SEND_NOTIFICATION_BODY, 10), true);
116
                $form->addElement($toCheckBox, true);
117
                $form->addElement(new \XoopsFormHidden('event_id', \Xmf\Request::getInt('event_id', 0, 'GET'), false));
0 ignored issues
show
Unused Code introduced by
The call to XoopsFormHidden::__construct() has too many arguments starting with false. ( Ignorable by Annotation )

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

117
                $form->addElement(/** @scrutinizer ignore-call */ new \XoopsFormHidden('event_id', \Xmf\Request::getInt('event_id', 0, 'GET'), false));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
118
                $form->addElement(new \XoopsFormButton('', 'mail_submit', _SUBMIT, 'submit'));
119
                $form->display();
120
                echo '</fieldset>';
121
122
                xoops_cp_footer();
123
124
                break;
125
        }
126
        break;
127
    default:
128
    case 'default':
129
        // @author      Gregory Mage (Aka Mage)
130
        //***************************************************************************************
131
        xoops_cp_header();
132
        //        require_once XOOPS_ROOT_PATH . "/modules/extcal/class/admin.php";
133
        //        $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
134
        //        $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
135
        $adminObject = \Xmf\Module\Admin::getInstance();
136
        $adminObject->addInfoBox(_MI_EXTCAL_DASHBOARD);
137
        $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_EXTCAL_INDEX_CATEGORIES . '</infolabel>', $categoryHandler->getCount()), '', 'Green');
138
        $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_EXTCAL_INDEX_EVENT . '</infolabel>', $eventHandler->getCount(new \Criteria('event_approved', 1))), '', 'Green');
139
        $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_EXTCAL_INDEX_PENDING . '</infolabel>', $eventHandler->getCount(new \Criteria('event_approved', 0))), '', 'Red');
140
        $criteriaCompo = new \CriteriaCompo();
141
        $criteriaCompo->add(new \Criteria('event_approved', 1));
142
        $criteriaCompo->add(new \Criteria('event_start', time(), '>='));
143
        $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_EXTCAL_INDEX_APPROVED . '</infolabel><infotext>', $eventHandler->getCount($criteriaCompo) . '</infotext>'), '', 'Green');
144
145
        $adminObject->addConfigBoxLine();
146
        $adminObject->addConfigBoxLine(_AM_EXTCAL_PEAR_PATH);
147
        $adminObject->addConfigBoxLine(_EXTCAL_PEAR_ROOT, 'folder');
148
149
        //JJD
150
        //         $adminObject->addConfigBoxLine(XOOPS_ROOT_PATH,'folder');
151
152
        //        $adminObject->addLineConfigLabel(_AM_EXTCAL_CONFIG_PHP, $xoopsModule->getInfo("min_php"), 'php');
153
        //        $adminObject->addLineConfigLabel(_AM_EXTCAL_CONFIG_XOOPS, $xoopsModule->getInfo("min_xoops"), 'xoops');
154
        $adminObject->displayNavigation(basename(__FILE__));
155
        $adminObject->displayIndex();
156
        //***************************************************************************************
157
        $pendingEvent = $eventHandler->objectToArray($eventHandler->getPendingEvent(), ['cat_id']);
158
        $eventHandler->formatEventsDate($pendingEvent, 'd/m/Y');
159
160
        echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTCAL_PENDING_EVENT . '</legend>';
161
        echo '<fieldset><legend style="font-weight:bold; color:#0A3760;">' . _AM_EXTCAL_INFORMATION . '</legend>';
162
        //        echo '<img src="../assets/images/icons/on.png" >&nbsp;&nbsp;'._AM_EXTCAL_INFO_APPROVE_PENDING_EVENT.'<br>';
163
        echo '<img src=' . $pathIcon16 . '/edit.png>&nbsp;&nbsp;' . _AM_EXTCAL_INFO_EDIT_PENDING_EVENT . '<br>';
164
        echo '<img src=' . $pathIcon16 . '/delete.png>&nbsp;&nbsp;' . _AM_EXTCAL_INFO_DELETE_PENDING_EVENT . '<br>';
165
        echo '</fieldset><br>';
166
167
        echo '<table class="outer" style="width:100%;">';
168
        echo '<tr style="text-align:center;">';
169
        echo '<th>' . _AM_EXTCAL_CATEGORY . '</th>';
170
        echo '<th>' . _AM_EXTCAL_TITLE . '</th>';
171
        echo '<th>' . _AM_EXTCAL_START_DATE . '</th>';
172
        echo '<th>' . _AM_EXTCAL_ACTION . '</th>';
173
        echo '</tr>';
174
175
        if (count($pendingEvent) > 0) {
176
            $i = 0;
177
            foreach ($pendingEvent as $event) {
178
                $class = (0 == ++$i % 2) ? 'even' : 'odd';
179
                echo '<tr style="text-align:center;" class="' . $class . '">';
180
                echo '<td>' . $event['Category']['cat_name'] . '</td>';
181
                echo '<td>' . $event['event_title'] . '</td>';
182
                echo '<td>' . $event['formated_event_start'] . '</td>';
183
                echo '<td style="width:10%; text-align:center;">';
184
                echo '<a href="event.php?op=modify&amp;event_id=' . $event['event_id'] . '"><img src=' . $pathIcon16 . '/edit.png></a>&nbsp;&nbsp;';
185
                echo '<a href="event.php?op=delete&amp;event_id=' . $event['event_id'] . '"><img src=' . $pathIcon16 . '/delete.png></a>';
186
                echo '</td>';
187
                echo '</tr>';
188
            }
189
        } else {
190
            echo '<tr><td colspan="4">' . _AM_EXTCAL_NO_PENDING_EVENT . '</td></tr>';
191
        }
192
193
        echo '</table></fieldset><br>';
194
195
        require_once __DIR__ . '/admin_footer.php';
196
197
        break;
198
}
199