|
1
|
|
|
<?php |
|
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
|
|
|
* tdmcreate module. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* |
|
18
|
|
|
* @since 2.5.5 |
|
19
|
|
|
* |
|
20
|
|
|
* @author Txmod Xoops <[email protected]> |
|
21
|
|
|
* |
|
22
|
|
|
* @version $Id: 1.59 addfiles.php 11297 2013-03-24 10:58:10Z timgno $ |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'tdmcreate_addfiles.tpl'; |
|
26
|
|
|
|
|
27
|
|
|
include __DIR__.'/header.php'; |
|
28
|
|
|
// Recovered value of argument op in the URL $ |
|
29
|
|
|
$op = \Xmf\Request::getString('op', 'list'); |
|
30
|
|
|
|
|
31
|
|
|
$fileId = \Xmf\Request::getInt('file_id'); |
|
32
|
|
|
|
|
33
|
|
|
switch ($op) { |
|
34
|
|
|
case 'list': |
|
35
|
|
|
default: |
|
36
|
|
|
$start = \Xmf\Request::getInt('start', 0); |
|
37
|
|
|
$limit = \Xmf\Request::getInt('limit', $helper->getConfig('addfiles_adminpager')); |
|
38
|
|
|
// Define main template |
|
39
|
|
|
// $templateMain = 'tdmcreate_addfiles.tpl'; |
|
40
|
|
|
$GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
|
41
|
|
|
$GLOBALS['xoTheme']->addStylesheet('modules/tdmcreate/assets/css/admin/style.css'); |
|
42
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('addfiles.php')); |
|
43
|
|
|
$adminObject->addItemButton(_AM_TDMCREATE_ADD_FILE, 'addfiles.php?op=new', 'add'); |
|
|
|
|
|
|
44
|
|
|
$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
45
|
|
|
$GLOBALS['xoopsTpl']->assign('tdmc_url', TDMC_URL); |
|
46
|
|
|
$GLOBALS['xoopsTpl']->assign('tdmc_upload_imgfile_url', TDMC_UPLOAD_IMGMOD_URL); |
|
47
|
|
|
$GLOBALS['xoopsTpl']->assign('modPathIcon16', $modPathIcon16); |
|
48
|
|
|
$GLOBALS['xoopsTpl']->assign('sysPathIcon32', $sysPathIcon32); |
|
49
|
|
|
$modulesCount = $helper->getHandler('Modules')->getCountModules(); |
|
50
|
|
|
// Redirect if there aren't modules |
|
51
|
|
|
if (0 == $modulesCount) { |
|
52
|
|
|
redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOT_MODULES); |
|
53
|
|
|
} |
|
54
|
|
|
$addfilesCount = $helper->getHandler('Addfiles')->getCountAddFiles(); |
|
55
|
|
|
$addfilesAll = $helper->getHandler('Addfiles')->getAllAddFiles($start, $limit); |
|
56
|
|
|
// Display addfiles list |
|
57
|
|
|
if ($addfilesCount > 0) { |
|
58
|
|
|
foreach (array_keys($addfilesAll) as $i) { |
|
59
|
|
|
$files = $addfilesAll[$i]->getAddFilesValues(); |
|
60
|
|
|
$GLOBALS['xoopsTpl']->append('files_list', $files); |
|
61
|
|
|
unset($files); |
|
62
|
|
|
} |
|
63
|
|
|
if ($addfilesCount > $limit) { |
|
64
|
|
|
include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
65
|
|
|
$pagenav = new \XoopsPageNav($addfilesCount, $limit, $start, 'start', 'op=list&limit='.$limit); |
|
66
|
|
|
$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
|
67
|
|
|
} |
|
68
|
|
|
} else { |
|
69
|
|
|
$GLOBALS['xoopsTpl']->assign('error', _AM_TDMCREATE_THEREARENT_MODULES); |
|
70
|
|
|
} |
|
71
|
|
|
break; |
|
72
|
|
|
|
|
73
|
|
|
case 'new': |
|
74
|
|
|
// Define main template |
|
75
|
|
|
// $templateMain = 'tdmcreate_addfiles.tpl'; |
|
76
|
|
|
$GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
|
77
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('addfiles.php')); |
|
78
|
|
|
$adminObject->addItemButton(_AM_TDMCREATE_ADDFILES_LIST, 'addfiles.php', 'list'); |
|
|
|
|
|
|
79
|
|
|
$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
80
|
|
|
|
|
81
|
|
|
$addfilesObj = $helper->getHandler('Addfiles')->create(); |
|
82
|
|
|
$form = $addfilesObj->getFormAddFiles(); |
|
83
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
84
|
|
|
break; |
|
85
|
|
|
|
|
86
|
|
|
case 'save': |
|
87
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
|
88
|
|
|
redirect_header('addfiles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
89
|
|
|
} |
|
90
|
|
|
if (isset($fileId)) { |
|
91
|
|
|
$addfilesObj = $helper->getHandler('Addfiles')->get($fileId); |
|
92
|
|
|
} else { |
|
93
|
|
|
$addfilesObj = $helper->getHandler('Addfiles')->create(); |
|
94
|
|
|
} |
|
95
|
|
|
// Form file save |
|
96
|
|
|
$addfilesObj->setVars([ |
|
97
|
|
|
'file_mid' => $_POST['file_mid'], |
|
98
|
|
|
'file_name' => $_POST['file_name'], |
|
99
|
|
|
'file_extension' => $_POST['file_extension'], |
|
100
|
|
|
'file_infolder' => $_POST['file_infolder'], |
|
101
|
|
|
]); |
|
102
|
|
|
|
|
103
|
|
|
if ($helper->getHandler('Addfiles')->insert($addfilesObj)) { |
|
104
|
|
|
if ($addfilesObj->isNew()) { |
|
105
|
|
|
redirect_header('addfiles.php', 5, sprintf(_AM_TDMCREATE_FILE_FORM_CREATED_OK, $_POST['file_name'])); |
|
106
|
|
|
} else { |
|
107
|
|
|
redirect_header('addfiles.php', 5, sprintf(_AM_TDMCREATE_FILE_FORM_UPDATED_OK, $_POST['file_name'])); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$GLOBALS['xoopsTpl']->assign('error', $addfilesObj->getHtmlErrors()); |
|
112
|
|
|
$form = &$addfilesObj->getFormAddFiles(); |
|
113
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
114
|
|
|
break; |
|
115
|
|
|
|
|
116
|
|
|
case 'edit': |
|
117
|
|
|
// Define main template |
|
118
|
|
|
// $templateMain = 'tdmcreate_addfiles.tpl'; |
|
119
|
|
|
$GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
|
120
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('addfiles.php')); |
|
121
|
|
|
$adminObject->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'addfiles.php?op=new', 'add'); |
|
122
|
|
|
$adminObject->addItemButton(_AM_TDMCREATE_ADDFILES_LIST, 'addfiles.php', 'list'); |
|
123
|
|
|
$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
|
124
|
|
|
|
|
125
|
|
|
$addfilesObj = $helper->getHandler('Addfiles')->get($fileId); |
|
126
|
|
|
$form = $addfilesObj->getFormAddFiles(); |
|
127
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
128
|
|
|
break; |
|
129
|
|
|
|
|
130
|
|
|
case 'delete': |
|
131
|
|
|
$addfilesObj = $helper->getHandler('Addfiles')->get($fileId); |
|
132
|
|
|
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
|
133
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
|
134
|
|
|
redirect_header('addfiles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
135
|
|
|
} |
|
136
|
|
|
if ($helper->getHandler('Addfiles')->delete($addfilesObj)) { |
|
137
|
|
|
redirect_header('addfiles.php', 3, _AM_TDMCREATE_FORM_DELETED_OK); |
|
138
|
|
|
} else { |
|
139
|
|
|
$GLOBALS['xoopsTpl']->assign('error', $addfilesObj->getHtmlErrors()); |
|
140
|
|
|
} |
|
141
|
|
|
} else { |
|
142
|
|
|
xoops_confirm(['ok' => 1, 'file_id' => $fileId, 'op' => 'delete'], $_SERVER['REQUEST_URI'], sprintf(_AM_TDMCREATE_FORM_SURE_DELETE, $addfilesObj->getVar('file_name'))); |
|
143
|
|
|
} |
|
144
|
|
|
break; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
include __DIR__.'/footer.php'; |
|
148
|
|
|
|