Location: PHPKode > projects > Exero CMS > upload/admin/modules.php
<?
/*========================================*\
| Exero CMS                                |
|==========================================|
|          http://ecms.getox.net           |
|https://sourceforge.net/projects/exerocms/|
|==========================================|
|     Exero CMS is released under the      |
|     GNU General Public License (GPL)     |
| opensource.org/licenses/gpl-license.php  |
\*========================================*/

require("global.php");
if(!checkadminsession()) {
	print_login();
	exit;
}

if(!adminpermissions("managemodules")) {
	print_no_permission();
	exit;
}

if($_REQUEST['do'] == "") {
	print_cp_header("Module Manager");
	
	print_table_header("Active Modules","2","0","1","100%","2");
	print_modulemanager_head();
	$getmodules = $db->query("SELECT * FROM modules WHERE editable='1' AND active='1' ORDER BY title ASC");
	while($moduleinfo = $db->fetch_array($getmodules)) {
		$settings = $db->num_rows($db->query("SELECT moduleident,editable FROM modulesettings WHERE moduleident='".$moduleinfo['ident']."' LIMIT 1"));
		print_modulemanager_row($moduleinfo['title'],$moduleinfo['ident'],$moduleinfo['active'],$settings);
	}
	print_table_footer();
	
	print_table_header("Inactive Modules","2","0","1","100%","0");
	print_modulemanager_head();
	$getmodules = $db->query("SELECT * FROM modules WHERE editable='1' AND active='0' ORDER BY title ASC");
	while($moduleinfo = $db->fetch_array($getmodules)) {
		$settings = $db->num_rows($db->query("SELECT moduleident,editable FROM modulesettings WHERE moduleident='".$moduleinfo['ident']."' LIMIT 1"));
		print_modulemanager_row($moduleinfo['title'],$moduleinfo['ident'],$moduleinfo['active'],$settings);
	}
	print_table_footer();
		
	print_cp_footer();
} else if($_REQUEST['do'] == "activate") {
	$db->query("UPDATE modules SET active='1' WHERE ident='".$db->real_escape_string($_REQUEST['ident'])."'");
	$moduleinfo = $db->query_first("SELECT ident,block FROM modules WHERE id='".$db->real_escape_string($_REQUEST['ident'])."' LIMIT 1");
	if(!$moduleinfo['block'] == "") {
		$db->query("UPDATE blocks SET active='1' WHERE ident='".$moduleinfo['block']."'");
	}
	print_redirect("modules.php","Module Activated.","Module Activated.");
} else if($_REQUEST['do'] == "deactivate") {
	$db->query("UPDATE modules SET active='0' WHERE ident='".$db->real_escape_string($_REQUEST['ident'])."'");
	$moduleinfo = $db->query_first("SELECT ident,block FROM modules WHERE id='".$db->real_escape_string($_REQUEST['ident'])."' LIMIT 1");
	if(!$moduleinfo['block'] == "") {
		$db->query("UPDATE blocks SET active='0' WHERE ident='".$moduleinfo['block']."'");
	}
	print_redirect("modules.php","Module Deactivated.","Module Deactivated.");
} else if($_REQUEST['do'] == "settings") {
	$getsettings = $db->query("SELECT * FROM modulesettings WHERE moduleident='".$db->real_escape_string($_REQUEST['ident'])."' AND editable='1'");
	if(empty($_REQUEST['action'])) {
		$moduleinfo = $db->query_first("SELECT * FROM modules WHERE ident='".$db->real_escape_string($_REQUEST['ident'])."' LIMIT 1");
		print_cp_header($moduleinfo['title']." Module Settings");
		
		print_form_header("modules.php?do=settings&action=save","settings");
		print_form_hiddenfield("ident",$_REQUEST['ident']);
		print_table_header("Module Settings","2");
		while($modulesetting = $db->fetch_array($getsettings)) {
			if($modulesetting['type'] == "groupselect") {
				print_form_multiselect($modulesetting['label'],$modulesetting['setting']."[]",5,grouparray("admincp"),$modulesetting['value']);
			} else if($modulesetting['type'] == "yesno") {
				print_form_yesno($modulesetting['label'],$modulesetting['setting'],$modulesetting['value']);
			} else {
				print_form_textbox($modulesetting['label'],$modulesetting['setting'],$modulesetting['value']);
			}
		}
		print_form_submit("Save",2);
		print_table_footer();
		print_form_footer();
			
		print_cp_footer();
	} else if($_REQUEST['action'] == "save") {
		while($modulesetting = $db->fetch_array($getsettings)) {
			if($modulesetting['type'] == "groupselect") {
				$value = implode(',',$_POST['postinggroups']);
				//print_r($value);
				$db->query("UPDATE modulesettings SET value='".$value."' WHERE moduleident='".$db->real_escape_string($_REQUEST['ident'])."' AND setting='".$modulesetting['setting']."'");
			} else {
				$db->query("UPDATE modulesettings SET value='".$_POST[$modulesetting['setting']]."' WHERE moduleident='".$db->real_escape_string($_REQUEST['ident'])."' AND setting='".$modulesetting['setting']."'");
			}
		}
		print_redirect("modules.php","Module Settings Saved","Module Settings Saved.");
	}
} else if($_REQUEST['do'] == "blocksettings") {
	if(empty($_REQUEST['action'])) {
		$moduleinfo = $db->query_first("SELECT * FROM ".TABLE_PREFIX."modules WHERE ident='".$db->real_escape_string($_REQUEST['ident'])."' LIMIT 1");
		print_cp_header($moduleinfo['title']." Module Block Settings");
		
			print_form_header("modules.php?do=blocksettings&action=save","blocksettings");
			print_form_hiddenfield("ident",$_REQUEST['ident']);
			print_table_header("Block Settings","2");
			print_block_multiselect("Hidden Blocks","blockshidden[]",5,$moduleinfo['blockshidden']);
			print_block_multiselect("Viewable Blocks<br /><em>If a block is set to Hidden and is selected in here, It will be Viewable.</em>","blocksviewable[]",5,$moduleinfo['blocksviewable']);
			print_form_submit("Save",2);
			print_table_footer();
			print_form_footer();
		
		print_cp_footer();
	} else if($_REQUEST['action'] == "save") {
		if($_POST['blockshidden'] != "") {
			$blockshidden = implode(',',$_POST['blockshidden']);
		}
		if($_POST['blocksviewable'] != "") {
			$blocksviewable = implode(',',$_POST['blocksviewable']);
		}
		$db->query("UPDATE ".TABLE_PREFIX."modules SET blockshidden='".$blockshidden."', blocksviewable='".$blocksviewable."' WHERE ident='".$db->real_escape_string($_POST['ident'])."' LIMIT 1");
		print_redirect("modules.php","Module Block Settings Saved","Module Block Settings Saved.");
	}
}
?>
Return current item: Exero CMS