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_extensions.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('extensions', 'adminpath')
65  );
66  $admin_page->addBreadcrumbLink(XoopsLocale::MAIN);
68  $admin_page->renderBreadcrumb();
69  $admin_page->renderTips();
70 
71  $system_extension = new SystemExtension();
72 
73  $extension = $system_extension->getExtensionList();
74 
75  $xoops->tpl()->assign('xoops', $xoops);
76  $xoops->tpl()->assign('extension_list', $extension);
77  // Call Footer
78  $xoops->footer();
79  break;
80 
81  case 'install':
82  $module = $system->cleanVars($_POST, 'dirname', '', 'string');
83  // Call Header
84  $xoops->header('admin:system/system_modules_logger.tpl');
85  // Define Stylesheet
86  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
87  // Define Breadcrumb and tips
88  $admin_page = new \Xoops\Module\Admin();
89  $admin_page->addBreadcrumbLink(SystemLocale::CONTROL_PANEL, \XoopsBaseConfig::get('url') . '/admin.php', true);
90  $admin_page->addBreadcrumbLink(
92  $system->adminVersion('extensions', 'adminpath')
93  );
94  $admin_page->addBreadcrumbLink(XoopsLocale::A_INSTALL);
95  $admin_page->renderBreadcrumb();
96 
97  $ret = array();
98  $system_extension = new SystemExtension();
99  $ret = $system_extension->install($module);
100  if ($ret) {
101  $xoops->tpl()->assign('install', 1);
102  $xoops->tpl()->assign('module', $ret);
103  $xoops->tpl()->assign('from_title', SystemLocale::EXTENSIONS_ADMINISTRATION);
104  $xoops->tpl()->assign('from_link', $system->adminVersion('extensions', 'adminpath'));
105  $xoops->tpl()->assign('title', XoopsLocale::A_INSTALL);
106  $xoops->tpl()->assign('log', $system_extension->trace);
107  } else {
108  print_r($system_extension->error);
109  //print_r($system_extension->trace);
110  }
111  $folder = array(1, 2, 3);
112  $system->cleanCache($folder);
113  //Set active modules in cache folder
114  $xoops->setActiveModules();
115  // Call Footer
116  $xoops->footer();
117  break;
118 
119  case 'uninstall':
120  $mid = $system->cleanVars($_POST, 'mid', 0, 'int');
121  $module_handler = $xoops->getHandlerModule();
122  $module = $module_handler->getById($mid);
123  // Call Header
124  $xoops->header('admin:system/system_modules_logger.tpl');
125  // Define Stylesheet
126  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
127  // Define Breadcrumb and tips
128  $admin_page = new \Xoops\Module\Admin();
129  $admin_page->addBreadcrumbLink(SystemLocale::CONTROL_PANEL, \XoopsBaseConfig::get('url') . '/admin.php', true);
130  $admin_page->addBreadcrumbLink(
132  $system->adminVersion('extensions', 'adminpath')
133  );
134  $admin_page->addBreadcrumbLink(XoopsLocale::A_UNINSTALL);
135  $admin_page->renderBreadcrumb();
136 
137  $ret = array();
138  $system_extension = new SystemExtension();
139  $ret = $system_extension->uninstall($module->getVar('dirname'));
140  $xoops->tpl()->assign('module', $ret);
141  if ($ret) {
142  $xoops->tpl()->assign('from_title', SystemLocale::EXTENSIONS_ADMINISTRATION);
143  $xoops->tpl()->assign('from_link', $system->adminVersion('extensions', 'adminpath'));
144  $xoops->tpl()->assign('title', XoopsLocale::A_UNINSTALL);
145  $xoops->tpl()->assign('log', $system_extension->trace);
146  }
147  $folder = array(1, 2, 3);
148  $system->cleanCache($folder);
149  //Set active modules in cache folder
150  $xoops->setActiveModules();
151  // Call Footer
152  $xoops->footer();
153  break;
154 
155  case 'update':
156  $mid = $system->cleanVars($_POST, 'mid', 0, 'int');
157  $module_handler = $xoops->getHandlerModule();
158  $block_handler = $xoops->getHandlerBlock();
159  $module = $module_handler->getById($mid);
160  // Call Header
161  $xoops->header('admin:system/system_modules_logger.tpl');
162  // Define Stylesheet
163  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
164  // Define Breadcrumb and tips
165  $admin_page = new \Xoops\Module\Admin();
166  $admin_page->addBreadcrumbLink(SystemLocale::CONTROL_PANEL, \XoopsBaseConfig::get('url') . '/admin.php', true);
167  $admin_page->addBreadcrumbLink(
169  $system->adminVersion('extensions', 'adminpath')
170  );
171  $admin_page->addBreadcrumbLink(XoopsLocale::A_UPDATE);
172  $admin_page->renderBreadcrumb();
173 
174  $ret = array();
175  $system_extension = new SystemExtension();
176  $ret = $system_extension->update($module->getVar('dirname'));
177  $xoops->tpl()->assign('module', $ret);
178  if ($ret) {
179  $xoops->tpl()->assign('install', 1);
180  $xoops->tpl()->assign('from_title', SystemLocale::EXTENSIONS_ADMINISTRATION);
181  $xoops->tpl()->assign('from_link', $system->adminVersion('extensions', 'adminpath'));
182  $xoops->tpl()->assign('title', XoopsLocale::A_UPDATE);
183  $xoops->tpl()->assign('log', $system_extension->trace);
184  }
185  $folder = array(1, 2, 3);
186  $system->cleanCache($folder);
187  //Set active modules in cache folder
188  $xoops->setActiveModules();
189  // Call Footer
190  $xoops->footer();
191  break;
192 }
$mid
Definition: index.php:39
const EXTENSION_TIPS
Definition: en_US.php:288
const A_INSTALL
Definition: en_US.php:101
const EXTENSIONS_ADMINISTRATION
Definition: en_US.php:286
$system
Definition: main.php:26
static getInstance()
Definition: system.php:46
static getInstance()
Definition: Xoops.php:160
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
exit
Definition: browse.php:104
$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