Exemple #1
0
    function _module() {
    //
    // main function for module
    //
        if (func_num_args()>0) {
            $arg_list = func_get_args();
            $post_vars = $arg_list[0];
            $get_vars = $arg_list[1];
            $post_files = $arg_list[2];  // comes from index.php
            $validuser = $arg_list[3];
            $isadmin = $arg_list[4];
            //print_r($arg_list);
        }

        $module = new module;

        switch ($get_vars["method"]) {
        case "SQL":
            if ($post_vars["submitsql"]) {
                $module->process_module_sql($post_vars, $get_vars, $post_files);
            }
            $module->form_module_sql($post_vars, $get_vars);
            break;
        case "LOC":
            if ($post_vars["submitaccess"]) {
                $module->process_permissions($post_vars, $get_vars);
            }
            $module->form_locations($post_vars, $get_vars);
            break;
        case "MENU":
            if ($get_vars["moveup"] || $get_vars["movedown"]) {
                $module->process_order($post_vars, $get_vars);
                //header("location: ".$_SERVER["PHP_SELF"]."?page=MODULES&method=MENU");
            }
            $module->form_menuorder($post_vars, $get_vars);
            break;
        case "HELP":
            site::display_file("../module.help.php");
            break;
        case "PERMS":
            if ($post_vars["submitaccess"]) {
                $module->process_permissions($post_vars, $get_vars);
            }
            $module->form_permissions($post_vars, $get_vars);
            break;
        case "INIT":
            if ($post_vars["submitinitmod"]=="Update Activation Status") {
                $module->process_initmodule($post_vars);
                // comment out line below for debugging
                // while developing modules
                //header("location: ".$_SERVER["PHP_SELF"]."?page=MODULES&method=INIT&initmod=1");
            }
            // module activation
            $module->form_initmodule();
            break;
        case "MODDB":
        default:
            switch ($post_vars["submitmodule"]) {
            case "Yes, Delete Module":
                $module->delete_module($post_vars);
                header("location: ".$_SERVER["PHP_SELF"]."?page=MODULES");
                break;
            case "Delete Module":
                print "<font color='red' size='3'><b>Are you sure you want to DELETE this module?</b></font>";
                $module->form_module($get_vars, $post_vars);
                break;
            case "Add Module":
            default:
                if ($module_id = $module->process_module($post_vars, $post_files)) {
                    // comment out line below for debugging
                    // while developing modules
                    //header("location: ".$_SERVER["PHP_SELF"]."?page=MODULES");
                }
                $module->form_module($get_vars, $post_vars);
                $module->display_modules();
            }
        }
    }
	/**
	 * main function for module
	 *
	 * @param array $post_vars Post Variables
	 * @param array $get_vars Get Variables
	 * @param array $post_files File Submission Data
	 * @param boolean $validuser valid user flag
	 * @param boolean $isadmin admin user flag
	 * @todo describe the functionality of the function in this documentation block
	 */
	function _module() {

		if (func_num_args()>0) {
			$this->arg_list = func_get_args();
			$this->post_vars = $this->arg_list[0];
			$this->get_vars = $this->arg_list[1];
			$this->post_files = $this->arg_list[2];  // comes from index.php
			$this->validuser = $this->arg_list[3];
			$this->isadmin = $this->arg_list[4];
		}

		$module = new module;

		switch ($this->get_vars["method"]) {
			case "SQL":
				if ($this->post_vars["submitsql"]) {
					$module->process_module_sql($this->post_vars, $this->get_vars, $this->post_files);
				}
				$module->form_module_sql($this->post_vars, $this->get_vars);
				break;
			case "LOC":
				if ($this->post_vars["submitaccess"]) {
					$module->process_permissions($this->post_vars, $this->get_vars);
				}
				$module->form_locations($this->post_vars, $this->get_vars);
				break;
			case "MENU":
				if ($this->get_vars["moveup"] || $this->get_vars["movedown"]) {
					$module->process_order($this->post_vars, $this->get_vars);
					//header("location: ".$_SERVER["PHP_SELF"]."?page=MODULES&method=MENU");
				}
				$module->form_menuorder($this->post_vars, $this->get_vars);
				break;
			case "HELP":
				site::display_file("../module.help.php");
				print "<h3>MODULE CLASS SOURCE CODE</h3>";
				print "<small>";
				show_source("../class.module.php");
				print "</small>";
				break;
			case "PERMS":
				if ($this->post_vars["submitaccess"]) {
					$module->process_permissions($this->post_vars, $this->get_vars);
				}
				$module->form_permissions($this->post_vars, $this->get_vars);
				break;
			case "INIT":
				if ($this->post_vars["submitinitmod"]=="Update Activation Status") {
					$module->process_initmodule($this->post_vars);
					// comment out line below for debugging
					// while developing modules
					//header("location: ".$_SERVER["PHP_SELF"]."?page=MODULES&method=INIT&initmod=1");
				}
				// module activation
				$module->form_initmodule();
				break;
			case "MODDB":
			default:
				switch ($this->post_vars["submitmodule"]) {
					case "Yes, Delete Module":
						$module->delete_module($this->post_vars);
						header("location: ".$_SERVER["PHP_SELF"]."?page=MODULES");
						break;
					case "Delete Module":
						print "<font color='red' size='3'><b>Are you sure you want to DELETE this module?</b></font>";
						$module->form_module($this->get_vars, $this->post_vars);
						break;
					case "Add Module":
					default:
						// Commented off by Aditya Naik for v1.9
						//if ($module_id = $module->process_module($this->post_vars, $this->post_files)) {
							// comment out line below for debugging
							// while developing modules
							//header("location: ".$_SERVER["PHP_SELF"]."?page=MODULES");
							//print "hello";
						//}

						// Added by Aditya Naik for v1.9
						// Moved out of the empty if loop
						$module_id = $module->process_module($this->post_vars, $this->post_files);

						// Added by Aditya Naik for v1.9
						// this will send the module id of the newly installed
						// module to the form module function
						$module->form_module($this->get_vars, $this->post_vars, $module_id);
					$module->display_modules();
				}
		}
	}