Файл: adultscript-2.0.3-pro/files/admin/modules/module/components/manage.php
Строк: 74
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_module_manage
{
private $db;
public function __construct()
{
$this->db = VF::factory('database');
}
public function render()
{
$errors = array();
$messages = array();
$warnings = array();
$page = (isset($_GET['page']) && is_numeric($_GET['page'])) ? (int) $_GET['page'] : 1;
if (isset($_POST['action']) && isset($_POST['module_id'])) {
$action = trim($_POST['action']);
$module_id = (int) trim($_POST['module_id']);
switch ($action) {
case 'enable':
$this->db->query("UPDATE #__module SET status = '1' WHERE module_id = ".$module_id." LIMIT 1");
$messages[] = 'Module Enabled!';
break;
case 'disable':
$this->db->query("UPDATE #__module SET status = '0' WHERE module_id = ".$module_id." LIMIT 1");
$messages[] = 'Module Disabled';
break;
case 'delete':
break;
default:
throw new Exception('Invalid module action specified!');
}
VF::cache_del('modules', 'config');
}
if (isset($_POST['submit_actions'])) {
$action = trim($_POST['action']);
$ids = $this->get_checkbox_ids();
if ($ids) {
if ($action == 'activate' OR $action == 'suspend') {
$status = ($action == 'activate') ? 1 : 0;
$msg = ($action == 'activate') ? 'enabled' : 'disabled';
$this->db->query("UPDATE #__module
SET status = '".$status."'
WHERE module_id IN (".implode(',', array_values($ids)).")");
$messages[] = 'Selected modules '.$msg.'!';
VF::cache_del('modules', 'config');
} elseif ($action == 'delete') {
foreach ($ids as $id) {
$this->delete_module($id);
}
} else {
$errors[] = 'Invalid action! What exactly did you select!?';
}
} else {
$errors[] = 'Please select at least one module!';
}
}
$this->db->query("SELECT COUNT(*) AS total_modules FROM #__module");
$modules_total = $this->db->fetch_field('total_modules');
$pagination = VPagination::get($page, $modules_total, 30);
$modules = $this->db->get_rows("SELECT * FROM #__module ORDER BY type ASC LIMIT ".$pagination['limit']);
$tpl = &VF::factory('template');
$tpl->menu = 'main';
$tpl->submenu = 'extend';
$tpl->extramenu = 'module_manage';
$tpl->meta_title = 'Admin::Main::Extend::Module';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->warnings = $warnings;
$tpl->modules = $modules;
$tpl->pagination = $pagination;
$tpl->providers = VF::cfg('library.providers');
$tpl->load(array('header', 'module_manage', 'footer'));
$tpl->display();
}
private function get_checkbox_ids()
{
$ids = array();
foreach ($_POST as $key => $value) {
if (strpos($key, 'checkbox_module_') !== FALSE) {
$ids[] = (int) str_replace('checkbox_module_', '', $key);
}
}
return $ids;
}
private function delete_module($id)
{
}
private function delete_modules($ids)
{
}
}
?>