Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
class MyModule extends Module {
...
	public function getPackageFields($vars=null) {
		// Load any helpers required to build the fields
		Loader::loadHelpers($this, array("Html"));
		
		// Set any module fields
		$fields = new ModuleFields();
		$fields->setHtml("
			<script type=\"text/javascript\">
				$(document).ready(function() {
					// Re-fetch module options
					$('#mymodule_group').change(function() {
						fetchModuleOptions();
					});
				});
			</script>
		");

		// Fetch all packages available for the given server or server group
		$module_row = null;
		if (isset($vars->module_group) && $vars->module_group == "") {
			// Set a module row if one is given
			if (isset($vars->module_row) && $vars->module_row > 0)
				$module_row = $this->getModuleRow($vars->module_row);
			else {
				// Set the first module row of any that exist
				$rows = $this->getModuleRows();
				if (isset($rows[0]))
					$module_row = $rows[0];
				unset($rows);
			}
		}
		else {
			// Set the first module row from the list of servers in the selected group
			$rows = $this->getModuleRows($vars->module_group);
			if (isset($rows[0]))
				$module_row = $rows[0];
			unset($rows);
		}

		// Build any HTML fields
		$select_options = array('one' => "One", 'two' => "Two");
		$field = $fields->label(Language::_("MyModule.package_fields.field1", true), "mymodule_field");
		$field->attach($fields->fieldSelect("meta[field]", $select_options, 
			$this->Html->ifSet($vars->meta['field']), array('id' => "mymodule_field")));
		$fields->setField($field);

		return $fields;
	}
...
}

 

getEmailTags()

 

getAdminAddFields($package, $vars=null)

 

getClientAddFields($package, $vars=null)

 

getAdminEditFields($package, $vars=null)

 

getAdminServiceInfo($service, $package)

 

getClientServiceInfo($service, $package)

 

getAdminTabs($package)

 

getClientTabs($package)

This method returns an array of key/value pairs with "module", "package", and "service" keys that refer to module, package, and service fields used in this module that may be used as tags in emails.

Code Block
languagephp
class MyModule extends Module {
...
	public function getEmailTags() {
        return array(
            'module' => array("field1", "password"),
            'package' => array("field"),
            'service' => array("mymodule_field")
        );
    }
...
}

 

getAdminAddFields($package, $vars=null)

This method returns a ModuleFields object containing fields displayed when an admin goes to create a service.

Code Block
languagephp
class MyModule extends Module {
...
	public function getAdminAddFields($package, $vars=null) {
        Loader::loadHelpers($this, array("Html"));
        
        $fields = new ModuleFields();
        
        // Create field label
        $mymodule_field = $fields->label(Language::_("MyModule.service_field.mymodule_field", true), "mymodule_field");
        // Create field and attach to label
        $mymodule_field->attach($fields->fieldText("mymodule_field", $this->Html->ifSet($vars->mymodule_field), array('id'=>"mymodule_field")));
		// Add a tooltip next to this field
        $tooltip = $fields->tooltip(Language::_("MyModule.service_field.tooltip.mymodule_field", true));
        $mymodule_field->attach($tooltip);
        // Set the field
        $fields->setField($mymodule_field);

		return $fields;
	}
...
}

 

getClientAddFields($package, $vars=null)

This method returns a ModuleFileds object containing fields displayed when a client goes to create a service.

This method is very similar to getAdminAddFields().

getAdminEditFields($package, $vars=null)

This method returns a ModuleFields object containing fields displayed when an admin goes to update a service.

This method is very similar to getAdminAddFields().

getAdminServiceInfo($service, $package)

This method returns the view that is displayed when an admin clicks an expandable service row to view details about a service.

Code Block
languagephp
class MyModule extends Module {
...
	public function getAdminServiceInfo($service, $package) {
        $row = $this->getModuleRow();
        
        // Load the view (admin_service_info.pdt) into this object, so helpers can be automatically added to the view
        $this->view = new View("admin_service_info", "default");
        $this->view->base_uri = $this->base_uri;
        $this->view->setDefaultView("components" . DS . "modules" . DS . "my_module" . DS);
        
        // Load the helpers required for this view
        Loader::loadHelpers($this, array("Form", "Html"));
        
        $this->view->set("module_row", $row);
        $this->view->set("package", $package);
        $this->view->set("service", $service);
        $this->view->set("service_fields", $this->serviceFieldsToObject($service->fields));
        
        return $this->view->fetch();
    }
...
}

 

getClientServiceInfo($service, $package)

This method returns the view that is displayed when a client clicks an expandable service row to view details about their service.

This method is very similar to getAdminServiceInfo().

getAdminTabs($package)

This method returns a list of key/value pairs representing tab names to display when an admin goes to manage a service.

Code Block
languagephp
class MyModule extends Module {
...
	public function getAdminTabs($package) {
		// The keys (i.e. "tabOne", "tabTwo") representing the method name of the tab to call when an admin clicks on it in the interface
        return array(
            'tabOne' => Language::_("MyModule.tab_one", true),
			'tabTwo' => Language::_("MyModule.tab_two", true)
        );
    }

	public function tabOne($package, $service, array $get=null, array $post=null, array $files=null) {
        $this->view = new View("tab_one", "default");
        // Load the helpers required for this view
        Loader::loadHelpers($this, array("Form", "Html"));
        
		// Set any specific data for this tab
		$tab_data = array();
        $this->view->set("tab_data", $tab_data);
        
        $this->view->setDefaultView("components" . DS . "modules" . DS . "my_module" . DS);
        return $this->view->fetch();
    }
	
	public function tabTwo($package, $service, array $get=null, array $post=null, array $files=null) {
        $this->view = new View("tab_two", "default");
        // Load the helpers required for this view
        Loader::loadHelpers($this, array("Form", "Html"));
        
		// Set any specific data for this tab
		$tab_data = array();
        $this->view->set("tab_data", $tab_data);
        
        $this->view->setDefaultView("components" . DS . "modules" . DS . "my_module" . DS);
        return $this->view->fetch();
    }
...
}

 

getClientTabs($package)

This method returns a list of key/value pairs representing tab names to display when a client goes to manage their service.

This method is very similar to getAdminTabs().