Completed
Push — master ( a9decc...a21b67 )
by Michael
02:51
created

main.php ➔ isUpToDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 7 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
require_once __DIR__ . '/../../../include/cp_header.php';
4
include __DIR__ . '/../../../class/xoopsformloader.php';
5
require_once __DIR__ . '/admin_header.php';
6
7
function extgalleryLastVersion()
8
{
9
    //return @file_get_contents("http://www.zoullou.net/extcal.version");  //the Website is not longer working
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
10
}
11
12
/**
13
 * @return bool
14
 */
15
function isUpToDate()
0 ignored issues
show
Coding Style introduced by
isUpToDate uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
16
{
17
    $version = extgalleryLastVersion();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $version is correct as extgalleryLastVersion() seems to always returns null.
Loading history...
18
19
    return $GLOBALS['xoopsModule']->getVar('version') >= $version;
20
}
21
22
if (isset($_GET['op'])) {
23
    $op = $_GET['op'];
24
} else {
25
    $op = 'default';
26
    if (isset($_POST['op'])) {
27
        $op = $_POST['op'];
28
    }
29
}
30
$fct = 'default';
31
if (isset($_GET['fct'])) {
32
    $fct = $_GET['fct'];
33
}
34
35
switch ($op) {
36
    case 'notification':
37
        switch ($fct) {
38
            case 'send':
39 View Code Duplication
                if (!$GLOBALS['xoopsSecurity']->check()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
                    redirect_header('index.php', 3, _NOPERM . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
41
                }
42
                xoops_cp_header();
43
                adminMenu(1);
44
45
                $myts        = MyTextSanitizer::getInstance();
46
                $xoopsMailer = xoops_getMailer();
47
                //                $catHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
                //                $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
49
                //                $eventMemberHandler = xoops_getModuleHandler(_EXTCAL_CLS_MEMBER, _EXTCAL_MODULE);
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
50
                $extcalTime        = ExtcalTime::getHandler();
51
                $extcalConfig      = ExtcalConfig::getHandler();
52
                $xoopsModuleConfig = $extcalConfig->getModuleConfig();
53
54
                $event = $eventHandler->getEvent($_POST['event_id'], $xoopsUser, true);
55
                $cat   = $catHandler->getCat($event->getVar('cat_id'), $xoopsUser, 'all');
56
57
                $xoopsMailer->setToUsers($eventMemberHandler->getMembers($_POST['event_id']));
58
                $xoopsMailer->setFromName($myts->oopsStripSlashesGPC($_POST['mail_fromname']));
59
                $xoopsMailer->setFromEmail($myts->oopsStripSlashesGPC($_POST['mail_fromemail']));
60
                $xoopsMailer->setSubject($myts->oopsStripSlashesGPC($_POST['mail_subject']));
61
                $xoopsMailer->setBody($myts->oopsStripSlashesGPC($_POST['mail_body']));
62
                if (in_array('mail', $_POST['mail_send_to'])) {
63
                    $xoopsMailer->useMail();
64
                }
65
                if (empty($_POST['mail_inactive']) && in_array('pm', $_POST['mail_send_to'])) {
66
                    $xoopsMailer->usePM();
67
                }
68
                $tag = array(
69
                    'EV_CAT'   => $cat->getVar('cat_name'),
70
                    'EV_TITLE' => $event->getVar('event_title'),
71
                    'EV_START' => $extcalTime->getFormatedDate($xoopsModuleConfig['date_long'], $event->getVar('event_start')),
72
                    'EV_END'   => $extcalTime->getFormatedDate($xoopsModuleConfig['date_long'], $event->getVar('event_end')),
73
                    'EV_LINK'  => XOOPS_URL . '/modules/extcal/event.php?event=' . $event->getVar('event_id'),
74
                );
75
                $xoopsMailer->assign($tag);
76
                $xoopsMailer->send(true);
77
                echo $xoopsMailer->getSuccess();
78
                echo $xoopsMailer->getErrors();
79
80
                xoops_cp_footer();
81
82
                break;
83
84
            case 'default':
85
            default:
86
                xoops_cp_header();
87
                $fromemail      = !empty($xoopsConfig['adminmail']) ? $xoopsConfig['adminmail'] : $xoopsUser->getVar('email', 'E');
88
                $subjectCaption = _AM_EXTCAL_SUBJECT
89
                                  . "<br><br><span style='font-size:x-small;font-weight:bold;'>"
90
                                  . _AM_EXTCAL_USEFUL_TAGS
91
                                  . "</span><br><span style='font-size:x-small;font-weight:normal;'>"
92
                                  . _AM_EXTCAL_MAILTAGS6
93
                                  . '<br>'
94
                                  . _AM_EXTCAL_MAILTAGS2
95
                                  . '</span>&nbsp;&nbsp;&nbsp;';
96
                $bodyCaption    = _AM_EXTCAL_BODY
97
                                  . "<br><br><span style='font-size:x-small;font-weight:bold;'>"
98
                                  . _AM_EXTCAL_USEFUL_TAGS
99
                                  . "</span><br><span style='font-size:x-small;font-weight:normal;'>"
100
                                  . _AM_EXTCAL_MAILTAGS1
101
                                  . '<br>'
102
                                  . _AM_EXTCAL_MAILTAGS2
103
                                  . '<br>'
104
                                  . _AM_EXTCAL_MAILTAGS3
105
                                  . '<br>'
106
                                  . _AM_EXTCAL_MAILTAGS4
107
                                  . '<br>'
108
                                  . _AM_EXTCAL_MAILTAGS5
109
                                  . '<br>'
110
                                  . _AM_EXTCAL_MAILTAGS6
111
                                  . '<br>'
112
                                  . _AM_EXTCAL_MAILTAGS7
113
                                  . '<br>'
114
                                  . _AM_EXTCAL_MAILTAGS8
115
                                  . '<br>'
116
                                  . _AM_EXTCAL_MAILTAGS9
117
                                  . '</span>&nbsp;&nbsp;&nbsp;';
118
                $toCheckBbox    = new XoopsFormCheckBox(_AM_EXTCAL_SEND_TO, 'mail_send_to', 'mail');
119
                $toCheckBox->addOption('mail', _AM_EXTCAL_EMAIL);
120
                $toCheckBox->addOption('pm', _AM_EXTCAL_PM);
121
122
                echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTCAL_APPROVED_EVENT . '</legend>';
123
                echo '<fieldset><legend style="font-weight:bold; color:#0A3760;">' . _AM_EXTCAL_INFORMATION . '</legend>';
124
                echo _AM_EXTCAL_INFO_SEND_NOTIF;
125
                echo '</fieldset><br>';
126
                $form = new XoopsThemeForm(_AM_EXTCAL_SEND_NOTIFICATION, 'mailusers', 'index.php?op=notification&amp;fct=send', 'post', true);
127
                $form->addElement(new XoopsFormText(_AM_EXTCAL_FROM_NAME, 'mail_fromname', 30, 255, $xoopsConfig['sitename']), true);
128
                $form->addElement(new XoopsFormText(_AM_EXTCAL_FROM_EMAIL, 'mail_fromemail', 30, 255, $fromemail), true);
129
                $form->addElement(new XoopsFormText($subjectCaption, 'mail_subject', 50, 255, _AM_EXTCAL_SEND_NOTIFICATION_SUBJECT), true);
130
                $form->addElement(new XoopsFormTextArea($bodyCaption, 'mail_body', _AM_EXTCAL_SEND_NOTIFICATION_BODY, 10), true);
131
                $form->addElement($toCheckBox, true);
132
                $form->addElement(new XoopsFormHidden('event_id', $_GET['event_id']), false);
133
                $form->addElement(new XoopsFormButton('', 'mail_submit', _SUBMIT, 'submit'));
134
                $form->display();
135
                echo '</fieldset>';
136
137
                xoops_cp_footer();
138
139
                break;
140
        }
141
        break;
142
143
    default:
144
    case 'default':
145
        // @author      Gregory Mage (Aka Mage)
146
        //***************************************************************************************
147
        xoops_cp_header();
148
        //        require_once XOOPS_ROOT_PATH . "/modules/extcal/class/admin.php";
149
        //        $catHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
150
        //        $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
151
        $adminObject  = \Xmf\Module\Admin::getInstance();
152
        $adminObject->addInfoBox(_MI_EXTCAL_DASHBOARD);
153
        $adminObject->addInfoBoxLine(_MI_EXTCAL_DASHBOARD, '<infolabel>' . _AM_EXTCAL_INDEX_CATEGORIES . '</infolabel>', $catHandler->getCount(), 'Green');
154
        $adminObject->addInfoBoxLine(_MI_EXTCAL_DASHBOARD, '<infolabel>' . _AM_EXTCAL_INDEX_EVENT . '</infolabel>', $eventHandler->getCount(new Criteria('event_approved', 1)), 'Green');
155
        $adminObject->addInfoBoxLine(_MI_EXTCAL_DASHBOARD, '<infolabel>' . _AM_EXTCAL_INDEX_PENDING . '</infolabel>', $eventHandler->getCount(new Criteria('event_approved', 0)), 'Red');
156
        $criteriaCompo = new CriteriaCompo();
157
        $criteriaCompo->add(new Criteria('event_approved', 1));
158
        $criteriaCompo->add(new Criteria('event_start', time(), '>='));
159
        $adminObject->addInfoBoxLine(_MI_EXTCAL_DASHBOARD, '<infolabel>' . _AM_EXTCAL_INDEX_APPROVED . '</infolabel><infotext>', $eventHandler->getCount($criteriaCompo) . '</infotext>', 'Green');
160
161
        $adminObject->addConfigBoxLine();
162
        $adminObject->addConfigBoxLine(_AM_EXTCAL_PEAR_PATH);
163
        $adminObject->addConfigBoxLine(_EXTCAL_PEAR_ROOT, 'folder');
164
165
        //JJD
166
        //         $adminObject->addConfigBoxLine(XOOPS_ROOT_PATH,'folder');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
167
168
        //        $adminObject->addLineConfigLabel(_AM_EXTCAL_CONFIG_PHP, $xoopsModule->getInfo("min_php"), 'php');
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
169
        //        $adminObject->addLineConfigLabel(_AM_EXTCAL_CONFIG_XOOPS, $xoopsModule->getInfo("min_xoops"), 'xoops');
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
170
        $adminObject->displayNavigation(basename(__FILE__));
171
        $adminObject->displayIndex();
172
        //***************************************************************************************
173
        $pendingEvent = $eventHandler->objectToArray($eventHandler->getPendingEvent(), array('cat_id'));
174
        $eventHandler->formatEventsDate($pendingEvent, 'd/m/Y');
175
176
        echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTCAL_PENDING_EVENT . '</legend>';
177
        echo '<fieldset><legend style="font-weight:bold; color:#0A3760;">' . _AM_EXTCAL_INFORMATION . '</legend>';
178
        //        echo '<img src="../assets/images/icons/on.png" >&nbsp;&nbsp;'._AM_EXTCAL_INFO_APPROVE_PENDING_EVENT.'<br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
179
        echo '<img src=' . $pathIcon16 . '/edit.png>&nbsp;&nbsp;' . _AM_EXTCAL_INFO_EDIT_PENDING_EVENT . '<br>';
180
        echo '<img src=' . $pathIcon16 . '/delete.png>&nbsp;&nbsp;' . _AM_EXTCAL_INFO_DELETE_PENDING_EVENT . '<br>';
181
        echo '</fieldset><br>';
182
183
        echo '<table class="outer" style="width:100%;">';
184
        echo '<tr style="text-align:center;">';
185
        echo '<th>' . _AM_EXTCAL_CATEGORY . '</th>';
186
        echo '<th>' . _AM_EXTCAL_TITLE . '</th>';
187
        echo '<th>' . _AM_EXTCAL_START_DATE . '</th>';
188
        echo '<th>' . _AM_EXTCAL_ACTION . '</th>';
189
        echo '</tr>';
190
191
        if (count($pendingEvent) > 0) {
192
            $i = 0;
193
            foreach ($pendingEvent as $event) {
194
                $class = (++$i % 2 == 0) ? 'even' : 'odd';
195
                echo '<tr style="text-align:center;" class="' . $class . '">';
196
                echo '<td>' . $event['cat']['cat_name'] . '</td>';
197
                echo '<td>' . $event['event_title'] . '</td>';
198
                echo '<td>' . $event['formated_event_start'] . '</td>';
199
                echo '<td style="width:10%; text-align:center;">';
200
                echo '<a href="event.php?op=modify&amp;event_id=' . $event['event_id'] . '"><img src=' . $pathIcon16 . '/edit.png></a>&nbsp;&nbsp;';
201
                echo '<a href="event.php?op=delete&amp;event_id=' . $event['event_id'] . '"><img src=' . $pathIcon16 . '/delete.png></a>';
202
                echo '</td>';
203
                echo '</tr>';
204
            }
205
        } else {
206
            echo '<tr><td colspan="4">' . _AM_EXTCAL_NO_PENDING_EVENT . '</td></tr>';
207
        }
208
209
        echo '</table></fieldset><br>';
210
211
        require_once __DIR__ . '/admin_footer.php';
212
213
        break;
214
}
215