extcalLastVersion()   A
last analyzed

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 Xmf\Module;
4
use Xmf\Request;
5
use XoopsModules\Extcal\{Helper,
6
    EventHandler,
7
    CategoryHandler,
8
    Common\TestdataButtons,
9
    Time
10
};
11
12
require_once __DIR__ . '/admin_header.php';
13
14
function extcalLastVersion()
15
{
16
    //return @file_get_contents("http://www.zoullou.net/extcal.version");  //the Website is not longer working
17
}
18
19
/**
20
 * @return bool
21
 */
22
function isUpToDate()
23
{
24
    $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...
25
26
    return $GLOBALS['xoopsModule']->getVar('version') >= $version;
27
}
28
29
global $xoopsUser, $xoopsConfig;
30
31
/** @var CategoryHandler $categoryHandler */
32
/** @var EventHandler $eventHandler */
33
/** @var EventmemberHandler $eventmemberHandler */
34
/** @var Helper $helper */
35
$helper = Helper::getInstance();
36
37
$op  = Request::getCmd('op', 'default');
38
$fct = Request::getString('fct', 'default', 'GET');
39
40
switch ($op) {
41
    case 'notification':
42
        switch ($fct) {
43
            case 'send':
44
                if (!$GLOBALS['xoopsSecurity']->check()) {
45
                    redirect_header('index.php', 3, _NOPERM . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
46
                }
47
                xoops_cp_header();
48
                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

48
                /** @scrutinizer ignore-call */ 
49
                adminMenu(1);
Loading history...
49
50
                $myts        = \MyTextSanitizer::getInstance();
51
                $xoopsMailer = xoops_getMailer();
52
                //                $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
53
                //                $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
54
                //                $eventmemberHandler = xoops_getModuleHandler(_EXTCAL_CLS_MEMBER, _EXTCAL_MODULE);
55
                $extcalTime = Time::getHandler();
56
57
                $event = $eventHandler->getEvent(Request::getInt('event_id', 0, 'POST'), $xoopsUser, true);
58
                $cat   = $categoryHandler->getCat($event->getVar('cat_id'), $xoopsUser, 'all');
59
60
                $xoopsMailer->setToUsers($eventmemberHandler->getMembers(Request::getInt('event_id', 0, 'POST')));
61
                $xoopsMailer->setFromName((Request::getString('mail_fromname', '', 'POST')));
62
                $xoopsMailer->setFromEmail((Request::getString('mail_fromemail', '', 'POST')));
63
                $xoopsMailer->setSubject((Request::getString('mail_subject', '', 'POST')));
64
                $xoopsMailer->setBody((Request::getString('mail_body', '', 'POST')));
65
                if (in_array('mail', Request::getString('mail_send_to', '', 'POST'))) {
0 ignored issues
show
Bug introduced by
Xmf\Request::getString('...l_send_to', '', 'POST') of type string is incompatible with the type array expected by parameter $haystack of in_array(). ( Ignorable by Annotation )

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

65
                if (in_array('mail', /** @scrutinizer ignore-type */ Request::getString('mail_send_to', '', 'POST'))) {
Loading history...
66
                    $xoopsMailer->useMail();
67
                }
68
                if (empty($_POST['mail_inactive']) && in_array('pm', Request::getString('mail_send_to', '', 'POST'))) {
69
                    $xoopsMailer->usePM();
70
                }
71
                $tag = [
72
                    'EV_CAT'   => $cat->getVar('cat_name'),
73
                    'EV_TITLE' => $event->getVar('event_title'),
74
                    'EV_START' => $extcalTime->getFormatedDate($helper->getConfig('date_long'), $event->getVar('event_start')),
75
                    'EV_END'   => $extcalTime->getFormatedDate($helper->getConfig('date_long'), $event->getVar('event_end')),
76
                    'EV_LINK'  => XOOPS_URL . '/modules/extcal/event.php?event=' . $event->getVar('event_id'),
77
                ];
78
                $xoopsMailer->assign($tag);
79
                $xoopsMailer->send(true);
80
                echo $xoopsMailer->getSuccess();
81
                echo $xoopsMailer->getErrors();
82
83
                xoops_cp_footer();
84
85
                break;
86
            case 'default':
87
            default:
88
                xoops_cp_header();
89
                $fromemail      = !empty($xoopsConfig['adminmail']) ? $xoopsConfig['adminmail'] : $xoopsUser->getVar('email', 'E');
90
                $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;';
91
                $bodyCaption    = _AM_EXTCAL_BODY
92
                                  . "<br><br><span style='font-size:x-small;font-weight:bold;'>"
93
                                  . _AM_EXTCAL_USEFUL_TAGS
94
                                  . "</span><br><span style='font-size:x-small;font-weight:normal;'>"
95
                                  . _AM_EXTCAL_MAILTAGS1
96
                                  . '<br>'
97
                                  . _AM_EXTCAL_MAILTAGS2
98
                                  . '<br>'
99
                                  . _AM_EXTCAL_MAILTAGS3
100
                                  . '<br>'
101
                                  . _AM_EXTCAL_MAILTAGS4
102
                                  . '<br>'
103
                                  . _AM_EXTCAL_MAILTAGS5
104
                                  . '<br>'
105
                                  . _AM_EXTCAL_MAILTAGS6
106
                                  . '<br>'
107
                                  . _AM_EXTCAL_MAILTAGS7
108
                                  . '<br>'
109
                                  . _AM_EXTCAL_MAILTAGS8
110
                                  . '<br>'
111
                                  . _AM_EXTCAL_MAILTAGS9
112
                                  . '</span>&nbsp;&nbsp;&nbsp;';
113
                $toCheckBbox    = new \XoopsFormCheckBox(_AM_EXTCAL_SEND_TO, 'mail_send_to', 'mail');
114
                $toCheckBox->addOption('mail', _AM_EXTCAL_EMAIL);
115
                $toCheckBox->addOption('pm', _AM_EXTCAL_PM);
116
117
                echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTCAL_APPROVED_EVENT . '</legend>';
118
                echo '<fieldset><legend style="font-weight:bold; color:#0A3760;">' . _AM_EXTCAL_INFORMATION . '</legend>';
119
                echo _AM_EXTCAL_INFO_SEND_NOTIF;
120
                echo '</fieldset><br>';
121
                $form = new \XoopsThemeForm(_AM_EXTCAL_SEND_NOTIFICATION, 'mailusers', 'index.php?op=notification&amp;fct=send', 'post', true);
122
                $form->addElement(new \XoopsFormText(_AM_EXTCAL_FROM_NAME, 'mail_fromname', 30, 255, $xoopsConfig['sitename']), true);
123
                $form->addElement(new \XoopsFormText(_AM_EXTCAL_FROM_EMAIL, 'mail_fromemail', 30, 255, $fromemail), true);
124
                $form->addElement(new \XoopsFormText($subjectCaption, 'mail_subject', 50, 255, _AM_EXTCAL_SEND_NOTIFICATION_SUBJECT), true);
125
                $form->addElement(new \XoopsFormTextArea($bodyCaption, 'mail_body', _AM_EXTCAL_SEND_NOTIFICATION_BODY, 10), true);
126
                $form->addElement($toCheckBox, true);
127
                $form->addElement(new \XoopsFormHidden('event_id', 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

127
                $form->addElement(/** @scrutinizer ignore-call */ new \XoopsFormHidden('event_id', 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...
128
                $form->addElement(new \XoopsFormButton('', 'mail_submit', _SUBMIT, 'submit'));
129
                $form->display();
130
                echo '</fieldset>';
131
132
                xoops_cp_footer();
133
134
                break;
135
        }
136
        break;
137
    default:
138
    case 'default':
139
        // @author      Gregory Mage (Aka Mage)
140
        //***************************************************************************************
141
        xoops_cp_header();
142
        //        require_once XOOPS_ROOT_PATH . "/modules/extcal/class/admin.php";
143
        //        $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
144
        //        $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
145
        $adminObject = Module\Admin::getInstance();
146
        $adminObject->addInfoBox(_MI_EXTCAL_DASHBOARD);
147
        $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_EXTCAL_INDEX_CATEGORIES . '</infolabel>', $categoryHandler->getCount()), '', 'Green');
148
        $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_EXTCAL_INDEX_EVENT . '</infolabel>', $eventHandler->getCount(new \Criteria('event_approved', 1))), '', 'Green');
149
        $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_EXTCAL_INDEX_PENDING . '</infolabel>', $eventHandler->getCount(new \Criteria('event_approved', 0))), '', 'Red');
150
        $criteriaCompo = new \CriteriaCompo();
151
        $criteriaCompo->add(new \Criteria('event_approved', 1));
152
        $criteriaCompo->add(new \Criteria('event_start', time(), '>='));
153
        $adminObject->addInfoBoxLine(sprintf('<infolabel>' . _AM_EXTCAL_INDEX_APPROVED . '</infolabel><infotext>', $eventHandler->getCount($criteriaCompo) . '</infotext>'), '', 'Green');
154
155
        $adminObject->addConfigBoxLine();
156
        $adminObject->addConfigBoxLine(_AM_EXTCAL_PEAR_PATH);
157
        $adminObject->addConfigBoxLine(_EXTCAL_PEAR_ROOT, 'folder');
158
159
        //JJD
160
        //         $adminObject->addConfigBoxLine(XOOPS_ROOT_PATH,'folder');
161
162
        //        $adminObject->addLineConfigLabel(_AM_EXTCAL_CONFIG_PHP, $xoopsModule->getInfo("min_php"), 'php');
163
        //        $adminObject->addLineConfigLabel(_AM_EXTCAL_CONFIG_XOOPS, $xoopsModule->getInfo("min_xoops"), 'xoops');
164
        $adminObject->displayNavigation(basename(__FILE__));
165
    //------------- Test Data Buttons ----------------------------
166
    if ($helper->getConfig('displaySampleButton')) {
167
        TestdataButtons::loadButtonConfig($adminObject);
168
        $adminObject->displayButton('left', '');;
169
    }
170
    $op = Request::getString('op', 0, 'GET');
171
    switch ($op) {
172
        case 'hide_buttons':
173
            TestdataButtons::hideButtons();
174
            break;
175
        case 'show_buttons':
176
            TestdataButtons::showButtons();
177
            break;
178
    }
179
    //------------- End Test Data Buttons ----------------------------
180
181
182
    $adminObject->displayIndex();
183
        //***************************************************************************************
184
        $pendingEvent = $eventHandler->objectToArray($eventHandler->getPendingEvent(), ['cat_id']);
185
        $eventHandler->formatEventsDate($pendingEvent, 'd/m/Y');
186
187
        echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTCAL_PENDING_EVENT . '</legend>';
188
        echo '<fieldset><legend style="font-weight:bold; color:#0A3760;">' . _AM_EXTCAL_INFORMATION . '</legend>';
189
        echo '<img src=' . $pathIcon16 . '/on.png>&nbsp;&nbsp;' . _AM_EXTCAL_INFO_APPROVE_PENDING_EVENT . '<br>';
190
        echo '<img src=' . $pathIcon16 . '/edit.png>&nbsp;&nbsp;' . _AM_EXTCAL_INFO_EDIT_PENDING_EVENT . '<br>';
191
        echo '<img src=' . $pathIcon16 . '/delete.png>&nbsp;&nbsp;' . _AM_EXTCAL_INFO_DELETE_PENDING_EVENT . '<br>';
192
        echo '</fieldset><br>';
193
194
        echo '<table class="outer" style="width:100%;">';
195
        echo '<tr style="text-align:center;">';
196
        echo '<th>' . _AM_EXTCAL_CATEGORY . '</th>';
197
        echo '<th>' . _AM_EXTCAL_TITLE . '</th>';
198
        echo '<th>' . _AM_EXTCAL_START_DATE . '</th>';
199
        echo '<th>' . _AM_EXTCAL_ACTION . '</th>';
200
        echo '</tr>';
201
202
        if (count($pendingEvent) > 0) {
203
            $i = 0;
204
            foreach ($pendingEvent as $event) {
205
                $class = (0 == ++$i % 2) ? 'even' : 'odd';
206
                echo '<tr style="text-align:center;" class="' . $class . '">';
207
                echo '<td>' . $event['Category']['cat_name'] . '</td>';
208
                echo '<td>' . $event['event_title'] . '</td>';
209
                echo '<td>' . $event['formated_event_start'] . '</td>';
210
                echo '<td style="width:10%; text-align:center;">';
211
                echo '<a href="event.php?op=modify&amp;event_id=' . $event['event_id'] . '"><img src=' . $pathIcon16 . '/edit.png></a>&nbsp;&nbsp;';
212
                echo '<a href="event.php?op=delete&amp;event_id=' . $event['event_id'] . '"><img src=' . $pathIcon16 . '/delete.png></a>';
213
                echo '</td>';
214
                echo '</tr>';
215
            }
216
        } else {
217
            echo '<tr><td colspan="4">' . _AM_EXTCAL_NO_PENDING_EVENT . '</td></tr>';
218
        }
219
220
        echo '</table></fieldset><br>';
221
222
        require_once __DIR__ . '/admin_footer.php';
223
224
        break;
225
}
226