XOOPS  2.6.0
admin.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 
14 
25 // Include header
26 include __DIR__ . '/header.php';
27 
28 // Get main instance
32 
33 $error = false;
34 if ($system->checkRight()) {
35  if (isset($fct) && $fct != '') {
36  $fct = preg_replace("/[^a-z0-9_\-]/i", "", $fct);
37  if (XoopsLoad::fileExists($file = $xoops->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/admin/' . $fct . '/xoops_version.php'))) {
38  // Load language file
39  //system_loadLanguage($fct, $xoopsModule->getVar('dirname', 'n'));
40  // Include Configuration file
41  require $file;
42  unset($file);
43 
44  // Get System permission handler
45  $sysperm_handler = $xoops->getHandlerGroupperm();
46 
47  $category = !empty($modversion['category']) ? intval($modversion['category']) : 0;
48  unset($modversion);
49 
50  if ($category > 0) {
51  $group = $xoopsUser->getGroups();
52  if (in_array(FixedGroups::ADMIN, $group) || false != $sysperm_handler->checkRight('system_admin', $category, $group, $xoopsModule->getVar('mid'))) {
53  if (XoopsLoad::fileExists($file = $xoops->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/admin/' . $fct . '/main.php'))) {
54  include_once $file;
55  unset($file);
56  } else {
57  $error = true;
58  }
59  } else {
60  $error = true;
61  }
62  } elseif ($fct == 'version') {
63  if (XoopsLoad::fileExists($file = $xoops->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/admin/version/main.php'))) {
64  include_once $file;
65  unset($file);
66  } else {
67  $error = true;
68  }
69  } else {
70  $error = true;
71  }
72  } else {
73  $error = true;
74  }
75  } else {
76  $error = true;
77  }
78 }
79 
80 if (false != $error) {
81  $op = $system->cleanVars($_REQUEST, 'op', '', 'string');
82  if ($op == 'system_activate') {
83  \Xoops::getInstance()->logger()->quiet();
84  $part = $system->cleanVars($_REQUEST, 'type', '', 'string');
85  $config_handler = $xoops->getHandlerConfig();
86 
87  $criteria = new Criteria('conf_name', 'active_' . $part);
88  $configs = $config_handler->getConfigs($criteria);
89  foreach ($configs as $conf) {
90  /* @var $conf XoopsConfigItem */
91  if ($conf->getVar('conf_name') == 'active_' . $part) {
92  $conf->setVar('conf_value', !$conf->getVar('conf_value'));
93  $config_handler->insertConfig($conf);
94  }
95  }
96  exit;
97  }
98  // Define main template
99  $xoops->header('admin:system/system_index.tpl');
100  // Define Stylesheet
101  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
102  // Define scripts
103  $xoops->theme()->addBaseScriptAssets('@jquery.');
104  $xoops->theme()->addBaseScriptAssets('modules/system/js/admin.js');
105  // Define Breadcrumb and tips
106  $admin_page = new \Xoops\Module\Admin();
107  $admin_page->addBreadcrumbLink(SystemLocale::CONTROL_PANEL, \XoopsBaseConfig::get('url') . '/admin.php', true);
109  $admin_page->renderBreadcrumb();
111  $admin_page->renderTips();
112  $groups = $xoopsUser->getGroups();
113  $all_ok = false;
114  if (!in_array(FixedGroups::ADMIN, $groups)) {
115  $sysperm_handler = $xoops->getHandlerGroupperm();
116  $ok_syscats = $sysperm_handler->getItemIds('system_admin', $groups);
117  } else {
118  $all_ok = true;
119  }
120 
121  $admin_dir = \XoopsBaseConfig::get('root-path') . '/modules/system/admin';
122  $dirlist = XoopsLists::getDirListAsArray($admin_dir);
123  $inactive_section = array('blocksadmin', 'groups', 'modulesadmin', 'preferences', 'tplsets', 'extensions', 'users', 'services');
124  foreach ($dirlist as $directory) {
125  if (XoopsLoad::fileExists($file = $admin_dir . '/' . $directory . '/xoops_version.php')) {
126  require $file;
127  unset($file);
128 
129  if ($modversion['hasAdmin']) {
130  if ($xoops->getModuleConfig('active_' . $directory)) {
131  $category = isset($modversion['category']) ? intval($modversion['category']) : 0;
132  if (false != $all_ok || in_array($modversion['category'], $ok_syscats)) {
133  $menu['file'] = $directory;
134  $menu['title'] = trim($modversion['name']);
135  $menu['desc'] = str_replace('<br />', ' ', $modversion['description']);
136  $menu['icon'] = $modversion['image'];
137  $menu['status'] = true;
138  }
139  } else {
140  $category = isset($modversion['category']) ? intval($modversion['category']) : 0;
141  if (false != $all_ok || in_array($modversion['category'], $ok_syscats)) {
142  $menu['file'] = $directory;
143  $menu['title'] = trim($modversion['name']);
144  $menu['desc'] = str_replace('<br />', ' ', $modversion['description']);
145  $menu['icon'] = $modversion['image'];
146  $menu['status'] = false;
147  }
148  }
149  if (!in_array($directory, $inactive_section)) {
150  $menu['used'] = true;
151  }
152  switch ($directory) {
153  case 'groups':
154  $groups_Handler = $xoops->getHandlerGroup();
155  $groups = $groups_Handler->getCount();
156  $menu['infos'] = sprintf(SystemLocale::F_GROUPS_SPAN, $groups);
157  break;
158  case 'users':
159  $member_handler = $xoops->getHandlerUser();
160  $member = $member_handler->getCount();
161  $menu['infos'] = sprintf(SystemLocale::F_USERS_SPAN, $member);
162  break;
163  }
164  $xoops->tpl()->appendByRef('menu', $menu);
165  unset($menu);
166  }
167  unset($modversion);
168  }
169  }
170  unset($dirlist);
171  $xoops->footer();
172 }
$admin_page
if($uname== ''||$pass== '') $member_handler
Definition: checklogin.php:44
static getInstance($fct= '')
$xoopsModule
Definition: common.php:264
static getInstance()
Definition: system.php:46
static getInstance()
Definition: Xoops.php:160
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
$admin_dir
Definition: menu.php:39
$fct
Definition: header.php:46
if(is_object($xoops->user)) $all_ok
Definition: menu.php:29
exit
Definition: browse.php:104
const F_USERS_SPAN
Definition: en_US.php:313
const F_GROUPS_SPAN
Definition: en_US.php:305
$system
Definition: admin.php:30
$xoops
Definition: admin.php:25
$menu
static fileExists($file)
Definition: xoopsload.php:506
global $xoopsUser
Definition: config.php:132
if($_SERVER['REQUEST_METHOD']== 'POST') $config_handler
static get($name)
const CONTROL_PANEL
Definition: en_US.php:247
$configs
Definition: config.php:27
$error
Definition: admin.php:33
$modversion
$groups
$criteria
const TIPS_MAIN
Definition: en_US.php:401
const SYSTEM_CONFIGURATION
Definition: en_US.php:391
$system_breadcrumb
Definition: admin.php:31
$op