|
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(); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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'))) { |
|
|
|
|
|
|
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> '; |
|
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> '; |
|
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&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)); |
|
|
|
|
|
|
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> ' . _AM_EXTCAL_INFO_APPROVE_PENDING_EVENT . '<br>'; |
|
190
|
|
|
echo '<img src=' . $pathIcon16 . '/edit.png> ' . _AM_EXTCAL_INFO_EDIT_PENDING_EVENT . '<br>'; |
|
191
|
|
|
echo '<img src=' . $pathIcon16 . '/delete.png> ' . _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&event_id=' . $event['event_id'] . '"><img src=' . $pathIcon16 . '/edit.png></a> '; |
|
212
|
|
|
echo '<a href="event.php?op=delete&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
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
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.