XOOPS  2.6.0
main.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
22 // Get main instance
25 
26 // Check users rights
27 if (!$xoops->isUser() || !$xoops->isModule() || !$xoops->user->isAdmin($xoops->module->mid())) {
29 }
30 
31 //if (isset($_POST)) {
32 // foreach ($_POST as $k => $v) {
33 // ${$k} = $v;
34 // }
35 //}
36 
37 // Get Action type
38 $op = $system->cleanVars($_REQUEST, 'op', 'list', 'string');
39 $module = $system->cleanVars($_REQUEST, 'module', '', 'string');
40 
41 if (in_array($op, array('install', 'update', 'uninstall'))) {
42  if (!$xoops->security()->check()) {
43  $op = 'list';
44  }
45 }
46 $myts = MyTextsanitizer::getInstance();
47 
48 switch ($op) {
49 
50  case 'list':
51  // Call Header
52  $xoops->header('admin:system/system_modules.tpl');
53  // Define Stylesheet
54  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
55  // Define scripts
56  $xoops->theme()->addScript('media/jquery/plugins/jquery.jeditable.js');
57  $xoops->theme()->addScript('modules/system/js/admin.js');
58  $xoops->theme()->addScript('modules/system/js/module.js');
59  // Define Breadcrumb and tips
60  $admin_page = new \Xoops\Module\Admin();
61  $admin_page->addBreadcrumbLink(SystemLocale::CONTROL_PANEL, \XoopsBaseConfig::get('url') . '/admin.php', true);
62  $admin_page->addBreadcrumbLink(
64  $system->adminVersion('modulesadmin', 'adminpath')
65  );
66  $admin_page->addBreadcrumbLink(XoopsLocale::MAIN);
68  $admin_page->renderBreadcrumb();
69  $admin_page->renderTips();
70 
72 
73  $list = $system_module->getModuleList();
74  $install = $system_module->getInstalledModules();
75 
76  $view = $system->cleanVars($_COOKIE, 'xoopsModsView', 'large', 'string');
77  if ($view == 'large') {
78  $xoops->tpl()->assign('view_large', '');
79  $xoops->tpl()->assign('view_line', 'hide');
80  } else {
81  $xoops->tpl()->assign('view_large', 'hide');
82  $xoops->tpl()->assign('view_line', '');
83  }
84  $xoops->tpl()->assign('xoops', $xoops);
85  $xoops->tpl()->assign('modules_list', $list);
86  $xoops->tpl()->assign('modules_available', $install);
87  // Call Footer
88  $xoops->footer();
89  break;
90 
91  case 'rename':
92  $xoops->logger()->quiet();
93  //$xoops->disableErrorReporting();
94 
95  $mid = $system->cleanVars($_POST, 'id', 0, 'int');
96  $value = $system->cleanVars($_POST, 'value', '', 'string');
97  if ($mid != 0) {
98  $module_handler = $xoops->getHandlerModule();
99  $module = $module_handler->getById($mid);
100  $module->setVar('name', $value);
101  if ($module_handler->insertModule($module)) {
102  echo $value;
103 
104  }
105  }
106  break;
107 
108  case 'order':
109  // Get Module Handler
110  $module_handler = $xoops->getHandlerModule();
111  if (isset($_POST['mod'])) {
112  $i = 1;
113  foreach ($_POST['mod'] as $order) {
114  if ($order > 0) {
115  $module = $module_handler->getById($order);
116  //Change order only for visible modules
117  if ($module->getVar('weight') != 0) {
118  $module->setVar('weight', $i);
119  if (!$module_handler->insertModule($module)) {
120  $error = true;
121  }
122  ++$i;
123  }
124  }
125  }
126  }
127  exit;
128  break;
129 
130  case 'active':
131  $xoops->logger()->quiet();
132  //$xoops->disableErrorReporting();
133  // Get module handler
134  $module_handler = $xoops->getHandlerModule();
135  $block_handler = $xoops->getHandlerBlock();
136  $module_id = $system->cleanVars($_POST, 'mid', 0, 'int');
137  if ($module_id > 0) {
138  $module = $module_handler->getById($module_id);
139  $old = $module->getVar('isactive');
140  // Set value
141  $module->setVar('isactive', !$old);
142  if (!$module_handler->insertModule($module)) {
143  $error = true;
144  }
145  $blocks = $block_handler->getByModule($module_id);
146  /* @var $block XoopsBlock */
147  foreach ($blocks as $block) {
148  $block->setVar('isactive', !$old);
149  $block_handler->insertBlock($block);
150  }
151  //Set active modules in cache folder
152  $xoops->setActiveModules();
153  echo $module->getVar('isactive');
154  }
155  break;
156 
157  case 'display_in_menu':
158  $xoops->logger()->quiet();
159  //$xoops->disableErrorReporting();
160  // Get module handler
161  $module_handler = $xoops->getHandlerModule();
162  $module_id = $system->cleanVars($_POST, 'mid', 0, 'int');
163  if ($module_id > 0) {
164  $module = $module_handler->getById($module_id);
165  $old = $module->getVar('weight');
166  // Set value
167  $module->setVar('weight', !$old);
168  if (!$module_handler->insertModule($module)) {
169  $error = true;
170  } else {
171  echo !$old;
172  }
173  }
174  break;
175 
176  case 'install':
177  $module = $system->cleanVars($_POST, 'dirname', '', 'string');
178  // Call Header
179  $xoops->header('admin:system/system_modules_logger.tpl');
180  // Define Stylesheet
181  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
182  // Define Breadcrumb and tips
183  $admin_page = new \Xoops\Module\Admin();
184  $admin_page->addBreadcrumbLink(SystemLocale::CONTROL_PANEL, \XoopsBaseConfig::get('url') . '/admin.php', true);
185  $admin_page->addBreadcrumbLink(
187  $system->adminVersion('modulesadmin', 'adminpath')
188  );
189  $admin_page->addBreadcrumbLink(XoopsLocale::A_INSTALL);
190  $admin_page->renderBreadcrumb();
191 
192  $ret = array();
194  $ret = $system_module->install($module);
195  if ($ret) {
196  $xoops->tpl()->assign('install', 1);
197  $xoops->tpl()->assign('module', $ret);
198  $xoops->tpl()->assign('from_title', SystemLocale::MODULES_ADMINISTRATION);
199  $xoops->tpl()->assign('from_link', $system->adminVersion('modulesadmin', 'adminpath'));
200  $xoops->tpl()->assign('title', XoopsLocale::A_INSTALL);
201  $xoops->tpl()->assign('log', $system_module->trace);
202  } else {
203  print_r($system_module->error);
204  //print_r($system_module->trace);
205  }
206  $folder = array(1, 2, 3);
207  $system->cleanCache($folder);
208  //Set active modules in cache folder
209  $xoops->setActiveModules();
210  // Call Footer
211  $xoops->footer();
212  break;
213 
214  case 'uninstall':
215  $mid = $system->cleanVars($_POST, 'mid', 0, 'int');
216  $module_handler = $xoops->getHandlerModule();
217  $module = $module_handler->getById($mid);
218  // Call Header
219  $xoops->header('admin:system/system_modules_logger.tpl');
220  // Define Stylesheet
221  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
222  // Define Breadcrumb and tips
223  $admin_page = new \Xoops\Module\Admin();
224  $admin_page->addBreadcrumbLink(SystemLocale::CONTROL_PANEL, \XoopsBaseConfig::get('url') . '/admin.php', true);
225  $admin_page->addBreadcrumbLink(
227  $system->adminVersion('modulesadmin', 'adminpath')
228  );
229  $admin_page->addBreadcrumbLink(XoopsLocale::A_UNINSTALL);
230  $admin_page->renderBreadcrumb();
231 
232  $ret = array();
234  $ret = $system_module->uninstall($module->getVar('dirname'));
235  $xoops->tpl()->assign('module', $ret);
236  if ($ret) {
237  $xoops->tpl()->assign('from_title', SystemLocale::MODULES_ADMINISTRATION);
238  $xoops->tpl()->assign('from_link', $system->adminVersion('modulesadmin', 'adminpath'));
239  $xoops->tpl()->assign('title', XoopsLocale::A_UNINSTALL);
240  $xoops->tpl()->assign('log', $system_module->trace);
241  }
242  $folder = array(1, 2, 3);
243  $system->cleanCache($folder);
244  //Set active modules in cache folder
245  $xoops->setActiveModules();
246  // Call Footer
247  $xoops->footer();
248  break;
249 
250  case 'update':
251  $mid = $system->cleanVars($_POST, 'mid', 0, 'int');
252  $module_handler = $xoops->getHandlerModule();
253  $block_handler = $xoops->getHandlerBlock();
254  $module = $module_handler->getById($mid);
255  // Call Header
256  $xoops->header('admin:system/system_modules_logger.tpl');
257  // Define Stylesheet
258  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
259  // Define Breadcrumb and tips
260  $admin_page = new \Xoops\Module\Admin();
261  $admin_page->addBreadcrumbLink(SystemLocale::CONTROL_PANEL, \XoopsBaseConfig::get('url') . '/admin.php', true);
262  $admin_page->addBreadcrumbLink(
264  $system->adminVersion('modulesadmin', 'adminpath')
265  );
266  $admin_page->addBreadcrumbLink(XoopsLocale::A_UPDATE);
267  $admin_page->renderBreadcrumb();
268 
269  $ret = array();
271  $ret = $system_module->update($module->getVar('dirname'));
272  $xoops->tpl()->assign('module', $ret);
273  if ($ret) {
274  $xoops->tpl()->assign('install', 1);
275  $xoops->tpl()->assign('from_title', SystemLocale::MODULES_ADMINISTRATION);
276  $xoops->tpl()->assign('from_link', $system->adminVersion('modulesadmin', 'adminpath'));
277  $xoops->tpl()->assign('title', XoopsLocale::A_UPDATE);
278  $xoops->tpl()->assign('log', $system_module->trace);
279  }
280  $folder = array(1, 2, 3);
281  $system->cleanCache($folder);
282  //Set active modules in cache folder
283  $xoops->setActiveModules();
284  // Call Footer
285  $xoops->footer();
286  break;
287 }
$mid
Definition: index.php:39
if(empty($settings['ROOT_PATH'])) elseif(empty($settings['DB_PARAMETERS'])) $error
const A_INSTALL
Definition: en_US.php:101
$i
Definition: dialog.php:68
$system
Definition: main.php:26
static getInstance()
Definition: system.php:46
static getInstance()
Definition: Xoops.php:160
$module_id
Definition: update.php:56
if(in_array($op, array('install', 'update', 'uninstall'))) $myts
Definition: main.php:46
$admin_page
Definition: main.php:34
const A_UNINSTALL
Definition: en_US.php:131
if(!isset($_SESSION['RF']["view_type"])) if(isset($_GET['view'])) $view
Definition: dialog.php:92
exit
Definition: browse.php:104
const MODULES_TIPS
Definition: en_US.php:343
$op
Definition: main.php:30
static get($name)
$module
Definition: main.php:52
const CONTROL_PANEL
Definition: en_US.php:247
const E_NO_ACCESS_PERMISSION
Definition: en_US.php:351
$module_handler
Definition: main.php:55
const A_UPDATE
Definition: en_US.php:132
$xoops
Definition: main.php:25
const MODULES_ADMINISTRATION
Definition: en_US.php:341