XoopsModules25x /
xhelp
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | /* |
||
| 4 | * You may not change or alter any portion of this comment or credits |
||
| 5 | * of supporting developers from this source code or any supporting source code |
||
| 6 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 7 | * |
||
| 8 | * This program is distributed in the hope that it will be useful, |
||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 11 | */ |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 15 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
| 16 | * @author Brian Wahoff <[email protected]> |
||
| 17 | * @author Eric Juden <[email protected]> |
||
| 18 | * @author XOOPS Development Team |
||
| 19 | */ |
||
| 20 | |||
| 21 | use Xmf\Module\Admin; |
||
| 22 | use Xmf\Request; |
||
| 23 | use XoopsModules\Xhelp\{ |
||
| 24 | Helper, |
||
| 25 | RoleHandler, |
||
| 26 | Session, |
||
| 27 | Utility |
||
| 28 | }; |
||
| 29 | |||
| 30 | require_once __DIR__ . '/admin_header.php'; |
||
| 31 | $session = Session::getInstance(); |
||
| 32 | $helper = Helper::getInstance(); |
||
| 33 | /** @var \XoopsModules\Xhelp\NotificationHandler $notificationHandler */ |
||
| 34 | $notificationHandler = $helper->getHandler('Notification'); |
||
| 35 | |||
| 36 | global $xoopsModule; |
||
| 37 | if (!$templates = $session->get('xhelp_notifications')) { |
||
| 38 | $templates = $xoopsModule->getInfo('_email_tpl'); |
||
| 39 | $session->set('xhelp_notifications', $templates); |
||
| 40 | } |
||
| 41 | $has_notifications = count($templates); |
||
| 42 | |||
| 43 | $aStaffSettings = [ |
||
| 44 | 2 => _AM_XHELP_STAFF_SETTING2, // 1 => _AM_XHELP_STAFF_SETTING1, -- removed because we don't need it |
||
| 45 | 3 => _AM_XHELP_STAFF_SETTING3, |
||
| 46 | 4 => _AM_XHELP_STAFF_SETTING4, |
||
| 47 | ]; |
||
| 48 | $aUserSettings = ['1' => _AM_XHELP_USER_SETTING1, '2' => _AM_XHELP_USER_SETTING2]; |
||
| 49 | |||
| 50 | // Also in profile.php |
||
| 51 | $aNotifications = [ |
||
| 52 | XHELP_NOTIF_NEWTICKET => [ |
||
| 53 | 'name' => _AM_XHELP_NOTIF_NEW_TICKET, |
||
| 54 | 'email_tpl' => [ |
||
| 55 | 1 => $templates[1], |
||
| 56 | 18 => $templates[18], |
||
| 57 | 20 => $templates[20], |
||
| 58 | 21 => $templates[21], |
||
| 59 | 22 => $templates[22], |
||
| 60 | 23 => $templates[23], |
||
| 61 | 24 => $templates[24], |
||
| 62 | ], |
||
| 63 | ], |
||
| 64 | XHELP_NOTIF_DELTICKET => [ |
||
| 65 | 'name' => _AM_XHELP_NOTIF_DEL_TICKET, |
||
| 66 | 'email_tpl' => [2 => $templates[2], 12 => $templates[12]], |
||
| 67 | ], |
||
| 68 | XHELP_NOTIF_EDITTICKET => [ |
||
| 69 | 'name' => _AM_XHELP_NOTIF_MOD_TICKET, |
||
| 70 | 'email_tpl' => [3 => $templates[3], 13 => $templates[13]], |
||
| 71 | ], |
||
| 72 | XHELP_NOTIF_NEWRESPONSE => [ |
||
| 73 | 'name' => _AM_XHELP_NOTIF_NEW_RESPONSE, |
||
| 74 | 'email_tpl' => [4 => $templates[4], 14 => $templates[14]], |
||
| 75 | ], |
||
| 76 | XHELP_NOTIF_EDITRESPONSE => [ |
||
| 77 | 'name' => _AM_XHELP_NOTIF_MOD_RESPONSE, |
||
| 78 | 'email_tpl' => [5 => $templates[5], 15 => $templates[15]], |
||
| 79 | ], |
||
| 80 | XHELP_NOTIF_EDITSTATUS => [ |
||
| 81 | 'name' => _AM_XHELP_NOTIF_MOD_STATUS, |
||
| 82 | 'email_tpl' => [6 => $templates[6], 16 => $templates[16]], |
||
| 83 | ], |
||
| 84 | XHELP_NOTIF_EDITPRIORITY => [ |
||
| 85 | 'name' => _AM_XHELP_NOTIF_MOD_PRIORITY, |
||
| 86 | 'email_tpl' => [7 => $templates[7], 17 => $templates[17]], |
||
| 87 | ], |
||
| 88 | XHELP_NOTIF_EDITOWNER => [ |
||
| 89 | 'name' => _AM_XHELP_NOTIF_MOD_OWNER, |
||
| 90 | 'email_tpl' => [8 => $templates[8], 11 => $templates[11]], |
||
| 91 | ], |
||
| 92 | XHELP_NOTIF_CLOSETICKET => [ |
||
| 93 | 'name' => _AM_XHELP_NOTIF_CLOSE_TICKET, |
||
| 94 | 'email_tpl' => [9 => $templates[9], 19 => $templates[19]], |
||
| 95 | ], |
||
| 96 | XHELP_NOTIF_MERGETICKET => [ |
||
| 97 | 'name' => _AM_XHELP_NOTIF_MERGE_TICKET, |
||
| 98 | 'email_tpl' => [10 => $templates[10], 25 => $templates[25]], |
||
| 99 | ], |
||
| 100 | ]; |
||
| 101 | |||
| 102 | $op = 'default'; |
||
| 103 | if (Request::hasVar('op', 'REQUEST')) { |
||
| 104 | $op = $_REQUEST['op']; |
||
| 105 | } |
||
| 106 | |||
| 107 | switch ($op) { |
||
| 108 | case 'edit': |
||
| 109 | edit(); |
||
| 110 | break; |
||
| 111 | case 'manage': |
||
| 112 | manage(); |
||
| 113 | break; |
||
| 114 | case 'modifyEmailTpl': |
||
| 115 | modifyEmailTpl(); |
||
| 116 | break; |
||
| 117 | default: |
||
| 118 | manage(); |
||
| 119 | } |
||
| 120 | |||
| 121 | function edit() |
||
| 122 | { |
||
| 123 | global $xoopsModule, $session, $aNotifications, $has_notifications, $aStaffSettings, $aUserSettings; |
||
| 124 | $helper = Helper::getInstance(); |
||
| 125 | |||
| 126 | if (Request::hasVar('id', 'REQUEST')) { |
||
| 127 | $id = Request::getInt('id', 0, 'REQUEST'); |
||
| 128 | } else { |
||
| 129 | // No id specified, return to manage page |
||
| 130 | $helper->redirect('admin/notifications.php?op=manage', 3, _AM_XHELP_MESSAGE_NO_ID); |
||
| 131 | } |
||
| 132 | |||
| 133 | /** @var \XoopsModules\Xhelp\NotificationHandler $notificationHandler */ |
||
| 134 | $notificationHandler = $helper->getHandler('Notification'); |
||
| 135 | $settings = $notificationHandler->get($id); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 136 | |||
| 137 | if (null === $settings || false === $settings) { |
||
| 138 | $helper->redirect('admin/notifications.php?op=manage', 3, _AM_XHELP_EDIT_ERR); |
||
| 139 | } |
||
| 140 | |||
| 141 | xoops_cp_header(); |
||
| 142 | //echo $oAdminButton->renderButtons('manNotify'); |
||
| 143 | $adminObject = Admin::getInstance(); |
||
| 144 | |||
| 145 | $adminObject->addItemButton(_AM_XHELP_TEXT_MANAGE_NOTIFICATIONS, 'notifications.php?op=manage', 'add'); |
||
| 146 | $adminObject->addItemButton(_AM_XHELP_MENU_MODIFY_EMLTPL, 'notifications.php?op=modifyEmailTpl', 'list'); |
||
| 147 | $adminObject->displayButton('left'); |
||
| 148 | |||
| 149 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 150 | |||
| 151 | $session->set('xhelp_return_page', mb_substr(mb_strstr($_SERVER['REQUEST_URI'], 'admin/'), 6)); |
||
| 152 | |||
| 153 | if (Request::hasVar('save_notification', 'POST')) { |
||
| 154 | $settings->setVar('staff_setting', Request::getInt('staff_setting', 0, 'POST')); |
||
| 155 | $settings->setVar('user_setting', Request::getInt('user_setting', 0, 'POST')); |
||
| 156 | if (XHELP_NOTIF_STAFF_DEPT == Request::getInt('staff_setting', 0, 'POST')) { |
||
| 157 | $settings->setVar('staff_options', $_POST['roles']); |
||
| 158 | } else { |
||
| 159 | $settings->setVar('staff_options', []); |
||
| 160 | } |
||
| 161 | $notificationHandler->insert($settings, true); |
||
| 162 | $helper->redirect("notifications.php?op=edit&id=$id"); |
||
| 163 | } |
||
| 164 | |||
| 165 | // Retrieve list of email templates |
||
| 166 | if (!$templates = $session->get('xhelp_notifications')) { |
||
|
0 ignored issues
–
show
|
|||
| 167 | $templates = $xoopsModule->getInfo('_email_tpl'); |
||
| 168 | $session->set('xhelp_notifications', $templates); |
||
| 169 | } |
||
| 170 | $notification = $aNotifications[$id]; |
||
| 171 | |||
| 172 | $staff_settings = Utility::getMeta("notify_staff{$id}"); |
||
|
0 ignored issues
–
show
|
|||
| 173 | $user_settings = Utility::getMeta("notify_user{$id}"); |
||
|
0 ignored issues
–
show
|
|||
| 174 | /** @var RoleHandler $roleHandler */ |
||
| 175 | $roleHandler = $helper->getHandler('Role'); |
||
| 176 | if (XHELP_NOTIF_STAFF_DEPT == $settings->getVar('staff_setting')) { |
||
| 177 | $selectedRoles = $settings->getVar('staff_options'); |
||
| 178 | } else { |
||
| 179 | $selectedRoles = []; |
||
| 180 | } |
||
| 181 | $roles = $roleHandler->getObjects(); |
||
| 182 | |||
| 183 | echo "<form method='post' action='" . XHELP_ADMIN_URL . '/notifications.php?op=edit&id=' . $id . "'>"; |
||
|
0 ignored issues
–
show
|
|||
| 184 | echo "<table width='100%' cellspacing='1' class='outer'>"; |
||
| 185 | echo "<tr><th colspan='2'>" . $notification['name'] . '</th></tr>'; |
||
| 186 | echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_NOTIF_STAFF . "</td> |
||
| 187 | <td class='even' valign='top'>"; |
||
| 188 | echo "<table border='0'>"; |
||
| 189 | echo '<tr>'; |
||
| 190 | foreach ($aStaffSettings as $value => $setting) { |
||
| 191 | echo "<td valign='top'>"; |
||
| 192 | if ($settings->getVar('staff_setting') == $value) { |
||
| 193 | $checked = 'checked'; |
||
| 194 | } else { |
||
| 195 | $checked = ''; |
||
| 196 | } |
||
| 197 | echo "<input type='radio' name='staff_setting' id='staff" . $value . "' value='" . $value . "' $checked> |
||
| 198 | <label for='staff" . $value . "'>" . $setting . '</label> '; |
||
| 199 | if (XHELP_NOTIF_STAFF_DEPT == $value) { |
||
| 200 | echo "<br><br> |
||
| 201 | <select name='roles[]' multiple='multiple'>"; |
||
| 202 | foreach ($roles as $role) { |
||
| 203 | $role_id = $role->getVar('id'); |
||
| 204 | if (in_array($role_id, $selectedRoles)) { |
||
| 205 | echo "<option value='" . $role_id . "' selected>" . $role->getVar('name') . '</option>'; |
||
| 206 | } else { |
||
| 207 | echo "<option value='" . $role_id . "'>" . $role->getVar('name') . '</option>'; |
||
| 208 | } |
||
| 209 | } |
||
| 210 | echo '</select>'; |
||
| 211 | } |
||
| 212 | echo '</td>'; |
||
| 213 | } |
||
| 214 | echo '</tr></table>'; |
||
| 215 | echo '</td> |
||
| 216 | </tr>'; |
||
| 217 | echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_NOTIF_USER . "</td> |
||
| 218 | <td class='even'>"; |
||
| 219 | foreach ($aUserSettings as $value => $setting) { |
||
| 220 | if ($settings->getVar('user_setting') == $value) { |
||
| 221 | $checked = 'checked'; |
||
| 222 | } else { |
||
| 223 | $checked = ''; |
||
| 224 | } |
||
| 225 | echo "<input type='radio' name='user_setting' id='user" . $value . "' value='" . $value . "' $checked> |
||
| 226 | <label for='user" . $value . "'>" . $setting . '</label> '; |
||
| 227 | } |
||
| 228 | echo '</td> |
||
| 229 | </tr>'; |
||
| 230 | echo "<tr> |
||
| 231 | <td class='head'></td> |
||
| 232 | <td class='even'><input type='submit' name='save_notification' value='" . _AM_XHELP_BUTTON_SUBMIT . "'></td> |
||
| 233 | </tr>"; |
||
| 234 | echo '</table></form><br>'; |
||
| 235 | |||
| 236 | echo "<table width='100%' cellspacing='1' class='outer'>"; |
||
| 237 | echo "<tr><th colspan='3'>" . _AM_XHELP_TEXT_ASSOC_TPL . '</th></tr>'; |
||
| 238 | echo "<tr class='head'><td>" . _AM_XHELP_TEXT_TEMPLATE_NAME . '</td> |
||
| 239 | <td>' . _AM_XHELP_TEXT_DESCRIPTION . '</td> |
||
| 240 | <td>' . _AM_XHELP_TEXT_ACTIONS . '</td></tr>'; |
||
| 241 | foreach ($notification['email_tpl'] as $template) { |
||
| 242 | echo "<tr class='even'> |
||
| 243 | <td>" . $template['title'] . '</a></td><td>' . $template['description'] . "</td> |
||
| 244 | <td><a href='" . XHELP_ADMIN_URL . 'notifications.php?op=modifyEmailTpl&file=' . $template['mail_template'] . ".tpl'> |
||
| 245 | <img src='" . XOOPS_URL . "/modules/xhelp/assets/images/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editNotification'></a> |
||
| 246 | </td> |
||
| 247 | </tr>"; |
||
| 248 | } |
||
| 249 | echo '</table>'; |
||
| 250 | |||
| 251 | xoops_cp_footer(); |
||
| 252 | } |
||
| 253 | |||
| 254 | function manage() |
||
| 255 | { |
||
| 256 | global $xoopsModule, $session, $aNotifications, $has_notifications, $xoopsDB, $aStaffSettings, $aUserSettings; |
||
| 257 | $helper = Helper::getInstance(); |
||
| 258 | |||
| 259 | xoops_cp_header(); |
||
| 260 | //echo $oAdminButton->renderButtons('manNotify'); |
||
| 261 | $adminObject = Admin::getInstance(); |
||
| 262 | |||
| 263 | $adminObject->addItemButton(_AM_XHELP_TEXT_MANAGE_NOTIFICATIONS, 'notifications.php?op=manage', 'add'); |
||
| 264 | $adminObject->addItemButton(_AM_XHELP_MENU_MODIFY_EMLTPL, 'notifications.php?op=modifyEmailTpl', 'list'); |
||
| 265 | |||
| 266 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 267 | $adminObject->displayButton('left'); |
||
| 268 | |||
| 269 | /** @var \XoopsModules\Xhelp\NotificationHandler $notificationHandler */ |
||
| 270 | $notificationHandler = $helper->getHandler('Notification'); |
||
| 271 | $settings = $notificationHandler->getObjects(null, true); |
||
| 272 | |||
| 273 | echo "<table width='100%' cellspacing='1' class='outer'>"; |
||
| 274 | echo "<tr><th colspan='3'>" . _AM_XHELP_TEXT_MANAGE_NOTIFICATIONS . '</th></tr>'; |
||
| 275 | if ($has_notifications) { |
||
| 276 | echo "<tr class='head'> |
||
| 277 | <td>" . _AM_XHELP_TEXT_NOTIF_NAME . '</td> |
||
| 278 | <td>' . _AM_XHELP_TEXT_SUBSCRIBED_MEMBERS . '</td> |
||
| 279 | <td>' . _AM_XHELP_TEXT_ACTIONS . '</td> |
||
| 280 | </tr>'; |
||
| 281 | foreach ($aNotifications as $template_id => $template) { |
||
| 282 | // if (isset($settings[$template_id])) { |
||
| 283 | $cSettings = $settings[$template_id] ?? ''; |
||
| 284 | // if (null !== $cSettings) { |
||
| 285 | // $staff_setting = $cSettings->getVar('staff_setting'); |
||
| 286 | // $user_setting = $cSettings->getVar('user_setting'); |
||
| 287 | $staff_setting = !empty($cSettings) ? $cSettings->getVar('staff_setting') : 0; |
||
| 288 | $user_setting = !empty($cSettings) ? $cSettings->getVar('user_setting') : 0; |
||
| 289 | // } |
||
| 290 | // Build text of who gets notification |
||
| 291 | if (XHELP_NOTIF_USER_YES == $user_setting) { |
||
| 292 | if (\XHELP_NOTIF_STAFF_NONE == $staff_setting) { |
||
| 293 | $sSettings = _AM_XHELP_TEXT_SUBMITTER; |
||
| 294 | } else { |
||
| 295 | $sSettings = $aStaffSettings[$staff_setting] . ' ' . _AM_XHELP_TEXT_AND . ' ' . _AM_XHELP_TEXT_SUBMITTER; |
||
| 296 | } |
||
| 297 | } elseif (\XHELP_NOTIF_STAFF_NONE == $staff_setting) { |
||
| 298 | $sSettings = ''; |
||
| 299 | } else { |
||
| 300 | $sSettings = $aStaffSettings[$staff_setting] ?? ''; |
||
| 301 | } |
||
| 302 | // End Build text of who gets notification |
||
| 303 | |||
| 304 | echo "<tr class='even'> |
||
| 305 | <td width='20%'>" . $template['name'] . '</td> |
||
| 306 | <td>' . $sSettings . "</td> |
||
| 307 | <td> |
||
| 308 | <a href='notifications.php?op=edit&id=" . $template_id . "'><img src='" . XOOPS_URL . "/modules/xhelp/assets/images/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editNotification'></a> |
||
| 309 | </td> |
||
| 310 | </tr>"; |
||
| 311 | } |
||
| 312 | } else { |
||
| 313 | // No notifications found (Should never happen) |
||
| 314 | echo "<tr><td class='even' colspan='3'>" . _AM_XHELP_TEXT_NO_RECORDS . '</td></tr>'; |
||
| 315 | } |
||
| 316 | echo '</table>'; |
||
| 317 | |||
| 318 | xoops_cp_footer(); |
||
| 319 | } |
||
| 320 | |||
| 321 | function modifyEmailTpl() |
||
| 322 | { |
||
| 323 | global $xoopsConfig, $session; |
||
| 324 | $helper = Helper::getInstance(); |
||
| 325 | |||
| 326 | if (is_dir(XOOPS_ROOT_PATH . '/modules/xhelp/language/' . $xoopsConfig['language'] . '/mail_template')) { |
||
| 327 | $opendir = opendir(XOOPS_ROOT_PATH . '/modules/xhelp/language/' . $xoopsConfig['language'] . '/mail_template/'); |
||
| 328 | $dir = XOOPS_ROOT_PATH . '/modules/xhelp/language/' . $xoopsConfig['language'] . '/mail_template/'; |
||
| 329 | $url = XOOPS_URL . '/modules/xhelp/language/' . $xoopsConfig['language'] . '/mail_template/'; |
||
|
0 ignored issues
–
show
|
|||
| 330 | } else { |
||
| 331 | $opendir = opendir(XOOPS_ROOT_PATH . '/modules/xhelp/language/english/mail_template/'); |
||
| 332 | $dir = XOOPS_ROOT_PATH . '/modules/xhelp/language/english/mail_template/'; |
||
| 333 | $url = XOOPS_URL . '/modules/xhelp/language/english/mail_template/'; |
||
| 334 | } |
||
| 335 | |||
| 336 | $notNames = [ |
||
| 337 | _MI_XHELP_DEPT_NEWTICKET_NOTIFYTPL => [ |
||
| 338 | _MI_XHELP_DEPT_NEWTICKET_NOTIFY, |
||
| 339 | _MI_XHELP_DEPT_NEWTICKET_NOTIFYDSC, |
||
| 340 | _MI_XHELP_DEPT_NEWTICKET_NOTIFYTPL, |
||
| 341 | ], |
||
| 342 | _MI_XHELP_DEPT_REMOVEDTICKET_NOTIFYTPL => [ |
||
| 343 | _MI_XHELP_DEPT_REMOVEDTICKET_NOTIFY, |
||
| 344 | _MI_XHELP_DEPT_REMOVEDTICKET_NOTIFYDSC, |
||
| 345 | _MI_XHELP_DEPT_REMOVEDTICKET_NOTIFYTPL, |
||
| 346 | ], |
||
| 347 | _MI_XHELP_DEPT_NEWRESPONSE_NOTIFYTPL => [ |
||
| 348 | _MI_XHELP_DEPT_NEWRESPONSE_NOTIFY, |
||
| 349 | _MI_XHELP_DEPT_NEWRESPONSE_NOTIFYDSC, |
||
| 350 | _MI_XHELP_DEPT_NEWRESPONSE_NOTIFYTPL, |
||
| 351 | ], |
||
| 352 | _MI_XHELP_DEPT_MODIFIEDRESPONSE_NOTIFYTPL => [ |
||
| 353 | _MI_XHELP_DEPT_MODIFIEDRESPONSE_NOTIFY, |
||
| 354 | _MI_XHELP_DEPT_MODIFIEDRESPONSE_NOTIFYDSC, |
||
| 355 | _MI_XHELP_DEPT_MODIFIEDRESPONSE_NOTIFYTPL, |
||
| 356 | ], |
||
| 357 | _MI_XHELP_DEPT_MODIFIEDTICKET_NOTIFYTPL => [ |
||
| 358 | _MI_XHELP_DEPT_MODIFIEDTICKET_NOTIFY, |
||
| 359 | _MI_XHELP_DEPT_MODIFIEDTICKET_NOTIFYDSC, |
||
| 360 | _MI_XHELP_DEPT_MODIFIEDTICKET_NOTIFYTPL, |
||
| 361 | ], |
||
| 362 | _MI_XHELP_DEPT_CHANGEDSTATUS_NOTIFYTPL => [ |
||
| 363 | _MI_XHELP_DEPT_CHANGEDSTATUS_NOTIFY, |
||
| 364 | _MI_XHELP_DEPT_CHANGEDSTATUS_NOTIFYDSC, |
||
| 365 | _MI_XHELP_DEPT_CHANGEDSTATUS_NOTIFYTPL, |
||
| 366 | ], |
||
| 367 | _MI_XHELP_DEPT_CHANGEDPRIORITY_NOTIFYTPL => [ |
||
| 368 | _MI_XHELP_DEPT_CHANGEDPRIORITY_NOTIFY, |
||
| 369 | _MI_XHELP_DEPT_CHANGEDPRIORITY_NOTIFYDSC, |
||
| 370 | _MI_XHELP_DEPT_CHANGEDPRIORITY_NOTIFYTPL, |
||
| 371 | ], |
||
| 372 | _MI_XHELP_DEPT_NEWOWNER_NOTIFYTPL => [ |
||
| 373 | _MI_XHELP_DEPT_NEWOWNER_NOTIFY, |
||
| 374 | _MI_XHELP_DEPT_NEWOWNER_NOTIFYDSC, |
||
| 375 | _MI_XHELP_DEPT_NEWOWNER_NOTIFYTPL, |
||
| 376 | ], |
||
| 377 | _MI_XHELP_DEPT_CLOSETICKET_NOTIFYTPL => [ |
||
| 378 | _MI_XHELP_DEPT_CLOSETICKET_NOTIFY, |
||
| 379 | _MI_XHELP_DEPT_CLOSETICKET_NOTIFYDSC, |
||
| 380 | _MI_XHELP_DEPT_CLOSETICKET_NOTIFYTPL, |
||
| 381 | ], |
||
| 382 | _MI_XHELP_TICKET_NEWOWNER_NOTIFYTPL => [ |
||
| 383 | _MI_XHELP_TICKET_NEWOWNER_NOTIFY, |
||
| 384 | _MI_XHELP_TICKET_NEWOWNER_NOTIFYDSC, |
||
| 385 | _MI_XHELP_TICKET_NEWOWNER_NOTIFYTPL, |
||
| 386 | ], |
||
| 387 | _MI_XHELP_TICKET_REMOVEDTICKET_NOTIFYTPL => [ |
||
| 388 | _MI_XHELP_TICKET_REMOVEDTICKET_NOTIFY, |
||
| 389 | _MI_XHELP_TICKET_REMOVEDTICKET_NOTIFYDSC, |
||
| 390 | _MI_XHELP_TICKET_REMOVEDTICKET_NOTIFYTPL, |
||
| 391 | ], |
||
| 392 | _MI_XHELP_TICKET_MODIFIEDTICKET_NOTIFYTPL => [ |
||
| 393 | _MI_XHELP_TICKET_MODIFIEDTICKET_NOTIFY, |
||
| 394 | _MI_XHELP_TICKET_MODIFIEDTICKET_NOTIFYDSC, |
||
| 395 | _MI_XHELP_TICKET_MODIFIEDTICKET_NOTIFYTPL, |
||
| 396 | ], |
||
| 397 | _MI_XHELP_TICKET_NEWRESPONSE_NOTIFYTPL => [ |
||
| 398 | _MI_XHELP_TICKET_NEWRESPONSE_NOTIFY, |
||
| 399 | _MI_XHELP_TICKET_NEWRESPONSE_NOTIFYDSC, |
||
| 400 | _MI_XHELP_TICKET_NEWRESPONSE_NOTIFYTPL, |
||
| 401 | ], |
||
| 402 | _MI_XHELP_TICKET_MODIFIEDRESPONSE_NOTIFYTPL => [ |
||
| 403 | _MI_XHELP_TICKET_MODIFIEDRESPONSE_NOTIFY, |
||
| 404 | _MI_XHELP_TICKET_MODIFIEDRESPONSE_NOTIFYDSC, |
||
| 405 | _MI_XHELP_TICKET_MODIFIEDRESPONSE_NOTIFYTPL, |
||
| 406 | ], |
||
| 407 | _MI_XHELP_TICKET_CHANGEDSTATUS_NOTIFYTPL => [ |
||
| 408 | _MI_XHELP_TICKET_CHANGEDSTATUS_NOTIFY, |
||
| 409 | _MI_XHELP_TICKET_CHANGEDSTATUS_NOTIFYDSC, |
||
| 410 | _MI_XHELP_TICKET_CHANGEDSTATUS_NOTIFYTPL, |
||
| 411 | ], |
||
| 412 | _MI_XHELP_TICKET_CHANGEDPRIORITY_NOTIFYTPL => [ |
||
| 413 | _MI_XHELP_TICKET_CHANGEDPRIORITY_NOTIFY, |
||
| 414 | _MI_XHELP_TICKET_CHANGEDPRIORITY_NOTIFYDSC, |
||
| 415 | _MI_XHELP_TICKET_CHANGEDPRIORITY_NOTIFYTPL, |
||
| 416 | ], |
||
| 417 | _MI_XHELP_TICKET_NEWTICKET_NOTIFYTPL => [ |
||
| 418 | _MI_XHELP_TICKET_NEWTICKET_NOTIFY, |
||
| 419 | _MI_XHELP_TICKET_NEWTICKET_NOTIFYDSC, |
||
| 420 | _MI_XHELP_TICKET_NEWTICKET_NOTIFYTPL, |
||
| 421 | ], |
||
| 422 | _MI_XHELP_TICKET_NEWTICKET_EMAIL_NOTIFYTPL => [ |
||
| 423 | _MI_XHELP_TICKET_NEWTICKET_EMAIL_NOTIFY, |
||
| 424 | _MI_XHELP_TICKET_NEWTICKET_EMAIL_NOTIFYDSC, |
||
| 425 | _MI_XHELP_TICKET_NEWTICKET_EMAIL_NOTIFYTPL, |
||
| 426 | ], |
||
| 427 | _MI_XHELP_TICKET_CLOSETICKET_NOTIFYTPL => [ |
||
| 428 | _MI_XHELP_TICKET_CLOSETICKET_NOTIFY, |
||
| 429 | _MI_XHELP_TICKET_CLOSETICKET_NOTIFYDSC, |
||
| 430 | _MI_XHELP_TICKET_CLOSETICKET_NOTIFYTPL, |
||
| 431 | ], |
||
| 432 | _MI_XHELP_TICKET_NEWUSER_NOTIFYTPL => [ |
||
| 433 | _MI_XHELP_TICKET_NEWUSER_NOTIFY, |
||
| 434 | _MI_XHELP_TICKET_NEWUSER_NOTIFYDSC, |
||
| 435 | _MI_XHELP_TICKET_NEWUSER_NOTIFYTPL, |
||
| 436 | ], |
||
| 437 | _MI_XHELP_TICKET_NEWUSER_ACT1_NOTIFYTPL => [ |
||
| 438 | _MI_XHELP_TICKET_NEWUSER_ACT1_NOTIFY, |
||
| 439 | _MI_XHELP_TICKET_NEWUSER_ACT1_NOTIFYDSC, |
||
| 440 | _MI_XHELP_TICKET_NEWUSER_ACT1_NOTIFYTPL, |
||
| 441 | ], |
||
| 442 | _MI_XHELP_TICKET_NEWUSER_ACT2_NOTIFYTPL => [ |
||
| 443 | _MI_XHELP_TICKET_NEWUSER_ACT2_NOTIFY, |
||
| 444 | _MI_XHELP_TICKET_NEWUSER_ACT2_NOTIFYDSC, |
||
| 445 | _MI_XHELP_TICKET_NEWUSER_ACT2_NOTIFYTPL, |
||
| 446 | ], |
||
| 447 | _MI_XHELP_TICKET_EMAIL_ERROR_NOTIFYTPL => [ |
||
| 448 | _MI_XHELP_TICKET_EMAIL_ERROR_NOTIFY, |
||
| 449 | _MI_XHELP_TICKET_EMAIL_ERROR_NOTIFYDSC, |
||
| 450 | _MI_XHELP_TICKET_EMAIL_ERROR_NOTIFYTPL, |
||
| 451 | ], |
||
| 452 | _MI_XHELP_DEPT_MERGE_TICKET_NOTIFYTPL => [ |
||
| 453 | _MI_XHELP_DEPT_MERGE_TICKET_NOTIFY, |
||
| 454 | _MI_XHELP_DEPT_MERGE_TICKET_NOTIFYDSC, |
||
| 455 | _MI_XHELP_DEPT_MERGE_TICKET_NOTIFYTPL, |
||
| 456 | ], |
||
| 457 | _MI_XHELP_TICKET_MERGE_TICKET_NOTIFYTPL => [ |
||
| 458 | _MI_XHELP_TICKET_MERGE_TICKET_NOTIFY, |
||
| 459 | _MI_XHELP_TICKET_MERGE_TICKET_NOTIFYDSC, |
||
| 460 | _MI_XHELP_TICKET_MERGE_TICKET_NOTIFYTPL, |
||
| 461 | ], |
||
| 462 | ]; |
||
| 463 | |||
| 464 | $notKeys = array_keys($notNames); |
||
| 465 | |||
| 466 | while (false !== ($file = readdir($opendir))) { |
||
| 467 | //Do not Display . |
||
| 468 | if (is_dir($file)) { |
||
| 469 | continue; |
||
| 470 | } |
||
| 471 | |||
| 472 | if (!in_array($file, $notKeys)) { |
||
| 473 | continue; |
||
| 474 | } |
||
| 475 | |||
| 476 | $aFile = []; |
||
| 477 | $aFile['name'] = $notNames[$file][0]; |
||
| 478 | $aFile['desc'] = $notNames[$file][1]; |
||
| 479 | $aFile['filename'] = $notNames[$file][2]; |
||
| 480 | $aFile['url'] = "notifications.php?op=modifyEmailTpl&file=$file"; |
||
| 481 | $aFiles[] = $aFile; |
||
| 482 | } |
||
| 483 | |||
| 484 | if (isset($_GET['file'])) { |
||
| 485 | xoops_cp_header(); |
||
| 486 | //echo $oAdminButton->renderButtons('manNotify'); |
||
| 487 | $adminObject = Admin::getInstance(); |
||
| 488 | $adminObject->addItemButton(_AM_XHELP_TEXT_MANAGE_NOTIFICATIONS, 'notifications.php?op=manage', 'add'); |
||
| 489 | $adminObject->addItemButton(_AM_XHELP_MENU_MODIFY_EMLTPL, 'notifications.php?op=modifyEmailTpl', 'list'); |
||
| 490 | |||
| 491 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 492 | $adminObject->displayButton('left'); |
||
| 493 | |||
| 494 | foreach ($aFiles as $file) { |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 495 | if (\Xmf\Request::getString('file', '', 'GET') == $file['filename']) { |
||
| 496 | $myFileName = $file['filename']; |
||
| 497 | $myFileDesc = $file['desc']; |
||
| 498 | $myName = $file['name']; |
||
| 499 | break; |
||
| 500 | } |
||
| 501 | } |
||
| 502 | if (!$has_write = is_writable($dir . $myFileName)) { |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 503 | $message = _AM_XHELP_MESSAGE_FILE_READONLY; |
||
| 504 | $handle = fopen($dir . $myFileName, 'rb'); |
||
| 505 | $fileSize = filesize($dir . $myFileName); |
||
| 506 | } elseif (Request::hasVar('editTemplate', 'POST')) { |
||
| 507 | $handle = fopen($dir . $myFileName, 'wb+'); |
||
| 508 | } else { |
||
| 509 | $handle = fopen($dir . $myFileName, 'rb+'); |
||
| 510 | $fileSize = filesize($dir . $myFileName); |
||
| 511 | } |
||
| 512 | |||
| 513 | if (Request::hasVar('editTemplate', 'POST')) { |
||
| 514 | if (Request::hasVar('templateText', 'POST')) { |
||
| 515 | $text = $_POST['templateText']; // Get new text for template |
||
| 516 | } else { |
||
| 517 | $text = ''; |
||
| 518 | } |
||
| 519 | |||
| 520 | if (!$returnPage = $session->get('xhelp_return_page')) { |
||
| 521 | $returnPage = false; |
||
| 522 | } |
||
| 523 | |||
| 524 | if (fwrite($handle, $text)) { |
||
| 525 | $message = _AM_XHELP_MESSAGE_FILE_UPDATED; |
||
| 526 | $fileSize = filesize($dir . $myFileName); |
||
| 527 | fclose($handle); |
||
| 528 | if ($returnPage) { |
||
| 529 | $helper->redirect((string)$returnPage); |
||
| 530 | } else { |
||
| 531 | $helper->redirect('admin/notifications.php'); |
||
| 532 | } |
||
| 533 | } else { |
||
| 534 | $message = _AM_XHELP_MESSAGE_FILE_UPDATED_ERROR; |
||
| 535 | $fileSize = filesize($dir . $myFileName); |
||
| 536 | fclose($handle); |
||
| 537 | if ($returnPage) { |
||
| 538 | $helper->redirect((string)$returnPage, 3, $message); |
||
| 539 | } else { |
||
| 540 | $helper->redirect('admin/notifications.php', 3, $message); |
||
| 541 | } |
||
| 542 | } |
||
| 543 | } |
||
| 544 | if (!$has_write) { |
||
| 545 | echo "<div id='readOnly' class='errorMsg'>"; |
||
| 546 | echo $message; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 547 | echo '</div>'; |
||
| 548 | } |
||
| 549 | |||
| 550 | echo "<form action='" . XHELP_ADMIN_URL . '/notifications.php?op=modifyEmailTpl&file=' . $myFileName . "' method='post'>"; |
||
|
0 ignored issues
–
show
|
|||
| 551 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||
| 552 | echo "<table width='100%' border='0' cellspacing='1' class='outer'> |
||
| 553 | <tr><th colspan='2'>" . $myName . "</th></tr> |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 554 | <tr><td colspan='2' class='head'>" . $myFileDesc . '</td></tr>'; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 555 | |||
| 556 | echo "<tr class='odd'> |
||
| 557 | <td><textarea name='templateText' cols='40' rows='40'>" . fread($handle, $fileSize) . "</textarea></td> |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 558 | <td valign='top'> |
||
| 559 | <b>" . _AM_XHELP_TEXT_GENERAL_TAGS . '</b> |
||
| 560 | <ul> |
||
| 561 | <li>' . _AM_XHELP_TEXT_GENERAL_TAGS1 . '</li> |
||
| 562 | <li>' . _AM_XHELP_TEXT_GENERAL_TAGS2 . '</li> |
||
| 563 | <li>' . _AM_XHELP_TEXT_GENERAL_TAGS3 . '</li> |
||
| 564 | <li>' . _AM_XHELP_TEXT_GENERAL_TAGS4 . '</li> |
||
| 565 | <li>' . _AM_XHELP_TEXT_GENERAL_TAGS5 . '</li> |
||
| 566 | </ul> |
||
| 567 | <br> |
||
| 568 | <u>' . _AM_XHELP_TEXT_TAGS_NO_MODIFY . '</u> |
||
| 569 | </td> |
||
| 570 | </tr>'; |
||
| 571 | |||
| 572 | if ($has_write) { |
||
| 573 | echo "<tr><td class='foot' colspan='2'><input type='submit' name='editTemplate' value='" . _AM_XHELP_BUTTON_UPDATE . "' class='formButton'></td></tr>"; |
||
| 574 | } |
||
| 575 | echo '</table></form>'; |
||
| 576 | } else { |
||
| 577 | xoops_cp_header(); |
||
| 578 | //echo $oAdminButton->renderButtons('manNotify'); |
||
| 579 | $adminObject = Admin::getInstance(); |
||
| 580 | $adminObject->addItemButton(_AM_XHELP_TEXT_MANAGE_NOTIFICATIONS, 'notifications.php?op=manage', 'add'); |
||
| 581 | $adminObject->addItemButton(_AM_XHELP_MENU_MODIFY_EMLTPL, 'notifications.php?op=modifyEmailTpl', 'list'); |
||
| 582 | |||
| 583 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 584 | $adminObject->displayButton('left'); |
||
| 585 | |||
| 586 | echo "<table width='100%' border='0' cellspacing='1' class='outer'> |
||
| 587 | <tr><th colspan='2'><label>" . _AM_XHELP_MENU_MODIFY_EMLTPL . "</label></th></tr> |
||
| 588 | <tr class='head'><td>" . _AM_XHELP_TEXT_TEMPLATE_NAME . '</td><td>' . _AM_XHELP_TEXT_DESCRIPTION . '</td></tr>'; |
||
| 589 | |||
| 590 | static $rowSwitch = 0; |
||
| 591 | foreach ($aFiles as $file) { |
||
| 592 | if (0 == $rowSwitch) { |
||
| 593 | echo "<tr class='odd'><td><a href='" . $file['url'] . "'>" . $file['name'] . '</a></td><td>' . $file['desc'] . '</td></tr>'; |
||
| 594 | $rowSwitch = 1; |
||
| 595 | } else { |
||
| 596 | echo "<tr class='even'><td><a href='" . $file['url'] . "'>" . $file['name'] . '</a></td><td>' . $file['desc'] . '</td></tr>'; |
||
| 597 | $rowSwitch = 0; |
||
| 598 | } |
||
| 599 | } |
||
| 600 | echo '</table>'; |
||
| 601 | } |
||
| 602 | require_once __DIR__ . '/admin_footer.php'; |
||
| 603 | } |
||
| 604 |