Location: PHPKode > scripts > Multi Search Module > multi-search-module/block_set.inc.php
<?php
/* block_set class - basic functions for controlling module appearance.
 *
 * Basic functions for controlling module appearance by
 * Matthew McNaney. Turned into a class for portability to other modules.
 *
 * @author Edward Ritter, Matthew McNaney
 * @version $Id: block_set.inc.php,v 1.5 2002/09/06 06:09:26 esritter Exp $
 * @module block_set
 * @modulegroup misc
 * @package phpWebSite
 */

class block_admin {

/**
 * block_set - controls module appearance.
 *
 * Basic setup function for controlling module placement,
 * visibility and title.
 *
 * @author Matthew McNaney, Edward Ritter
 * @param string mod: name of module
 */

	function block_set() {
    	global $mod, $table_prefix;
    	$box_title = ucwords($mod) ." Block Options";
    	$get_info = mysql_query ("SELECT block_pos, name, admin_only, user_only,
    	admin_inc FROM " . $table_prefix . "modules WHERE plug_dir = '$mod'");
    	list ($position, $title, $admin_only, $user_only,$admin_inc) = mysql_fetch_row ($get_info);
		// Block View
		$checked = " checked=\"checked\"";
    	$box_content = "
       		<table cellspacing=\"1\" cellpadding=\"2\" width=\"100%\" border=\"0\">
                <tr><td class=\"type5\" width=\"25%\">
                <form action=\"mod.php\" method=\"post\">
                <input type=\"hidden\" name=\"mod\" value=\"$mod\" />
                <input type=\"hidden\" name=\"op\" value=\"".$mod."_admin\" />
                <input type=\"hidden\" name=\"adminop\" value=\"view_option\" />
                <input type=\"radio\" name=\"view\" value=\"admin\"
				" . (($admin_only)?$checked:"") ." />Admin Only <br />
				<input type=\"radio\" name=\"view\" value=\"user\"
				" . (($user_only)?$checked:"") ." />User Only <br />
				<input type=\"radio\" name=\"view\" value=\"both\"
				" . (($user_only == 0 && $admin_only == 0)?$checked:"") ." />Both<br />
				<input type=\"submit\" value=\"Change View\" /></form></td>";
	
		// Block Positions
		/* List all the block position names in an array for making the 
	   	   block position dropdown choices */
    	$positions = array ("Off","Left","Top Center", "Right", "Middle Center",
	    	"Bottom Center", "Left & Top Center", "Left & Middle Center",
    		"Left & Bottom Center", "Left & Right", "Top Center & Middle Center",
    		"Top Center & Bottom Center", "Top Center and Right", "Middle Center & 
			Bottom Center", "Middle Center & Right", "Bottom Center & Right", 
			"Left, Top Center & Right", "Left, Middle Center & Right", "Left, 
			Bottom Center & Right", "Top Center, Middle Center & Right", "Top 
			Center, Bottom Center & Right", "Middle Center, Bottom Center & Right", 
			"Top Center, Middle Center & Left", "Top Center, Bottom Center & Left", 
			"Middle Center, Bottom Center & Left","Top Center, Middle Center & 
			Bottom Center","Top Center, Middle Center, Left & Right", "Top Center, 
			Bottom Center, Left & Right", "Middle Center, Bottom Center, Left & 
			Right", "Top Center, Middle Center, Bottom Center & Right", 
			"Top Center, Middle Center, Bottom Center & Left","All");
		$box_content .= "<td class=\"type5\">
        	<form action=\"./mod.php\" method=\"post\">
        	<input type=\"hidden\" name=\"mod\" value=\"$mod\" />
        	<input type=\"hidden\" name=\"op\" value=\"".$mod."_admin\" />
			<input type=\"hidden\" name=\"adminop\" value=\"change_position\" />
        	Position window: <select name=\"position\">";
		// Generate the dropdown from the $positions array
		$sel = " selected=\"selected\" ";
		while (list ($key, $val) = each ($positions)) {
			$box_content .="<option value=\"$key\"";
			if ($position == $key) {
				$box_content .= $sel;
			}
			$box_content .= ">$val</option>\n";
		}
		$box_content .= "</select><input type=\"submit\" value=\"Change\" /></form>";
    	
    	// Block Title
    	$box_content .= " <form action=\"./mod.php\" method=\"post\">
            <input type=\"hidden\" name=\"mod\" value=\"$mod\" />
            <input type=\"hidden\" name=\"op\" value=\"".$mod."_admin\" />
            <input type=\"hidden\" name=\"adminop\" value=\"change_title\" />
            <input type=\"text\" name=\"title\" size=\"30\" maxsize=\"100\" value=\"$title\" />
            <input type=\"submit\" value=\"Update Title\" />
        	</form></td><tr/><tr></table>";
    	themesidebox($box_title, $box_content);
	}

/**
 * change_title Changes the name of the module/block.
 *
 * @author Matthew McNaney, Edward Ritter
 * @param string title: changed title of module/block
 * @param string mod: module name (derived from plug_dir)
 */
	function change_title($title) {
    	global $mod, $table_prefix;
    	mysql_query ("UPDATE " . $table_prefix . "modules SET name='$title' WHERE plug_dir='$mod'");
    	$box_content = "<b/><div class=\"onebigger\" align=\"center\">
    		$mod's title successfully changed</div>";
    	return $box_content;
	}

/**
 * change_position - repositions module block
 *
 * @author Matthew McNaney, Edward Ritter
 * @param int position: 0-31 (32 possible positions)
 * @param string mod: module name (derived from plug_dir)
 */
	function change_position($position) {
    	global $mod, $table_prefix;
    	mysql_query ("UPDATE " . $table_prefix . "modules SET block_pos='$position' WHERE plug_dir='$mod'");
    	$box_content = "<br/><div class=\"onebigger\" align=\"center\">
    		$mod block successfully moved.</div>";
    	return $box_content;
	}

/**
 * view_option - who can view this module block.
 *
 * @author Matthew McNaney, Edward Ritter
 * @param string view: user, admin, both
 * @param string mod: module name (derived from plug_dir)
 */
	function view_option($view) {
    	global $mod, $table_prefix;
    	$sql_query = "UPDATE ".$table_prefix."modules SET ";

    	switch ($view) {
        	case ('user'):
            	$sql_query .= 'admin_only=0, user_only=1 ';
            	break;
        	case ('admin'):
            	$sql_query .= 'admin_only=1, user_only=0 ';
            	break;
        	case ('both'):
            	$sql_query .= 'admin_only=0, user_only=0 ';
            	break;
    	}
    	$sql_query .= "WHERE plug_dir='$mod'";
    	mysql_query ($sql_query);
    	$box_content = "<br/><div class=\"onebigger\" align=\"center\">
    		$mod block view successfully changed.</div>";
		return $box_content;
	}

}

?>
Return current item: Multi Search Module