-
Notifications
You must be signed in to change notification settings - Fork 1
/
request.php
66 lines (58 loc) · 2.97 KB
/
request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php declare(strict_types=1);
use XoopsModules\Songlist\Form\SelectCategoryForm;
use XoopsModules\Songlist\Form\SelectGenreForm;
use XoopsModules\Songlist\Helper;
use XoopsModules\Songlist\RequestsHandler;
use XoopsModules\Songlist\Form\FormController;
require_once __DIR__ . '/header.php';
global $file, $op, $fct, $id, $value, $gid, $cid, $singer, $start, $limit;
$category_element = new SelectCategoryForm('', 'cid', ($_GET['cid'] ?? $cid));
$genre_element = new SelectGenreForm('', 'gid', $gid);
$genre_element = new SelectGenreForm('', 'vid', $vid);
//$singer_element = new \XoopsModules\Songlist\Form\SelectSinger('', 'singer', $singer);
/** @var RequestsHandler $requestsHandler */
$requestsHandler = Helper::getInstance()->getHandler('Requests');
switch ($op) {
default:
case 'request':
$url = $requestsHandler->getURL();
if (!mb_strpos($url, $_SERVER['REQUEST_URI']) && empty($_POST)) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
exit(0);
}
switch ($fct) {
case 'save':
if (checkEmail($_POST[0]['email'], true) && !empty($_POST[0]['email'])) {
$request = $requestsHandler->create();
$request->setVars($_POST[0]);
$rid = $requestsHandler->insert($request);
if ($rid) {
redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT);
} else {
redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT);
}
exit;
break;
}
$error = _MD_SONGLIST_MSG_EMAILNOTSET;
// no break
default:
case 'list':
$GLOBALS['xoopsOption']['template_main'] = 'songlist_requests_index.tpl';
require_once $GLOBALS['xoops']->path('/header.php');
if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) {
$GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']);
$GLOBALS['loaded_jquery'] = true;
}
$GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']);
$GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
$GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
$GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false, false));
if (mb_strlen($error ?? '')) {
xoops_error($error);
}
require_once $GLOBALS['xoops']->path('/footer.php');
break;
}
}