Skip to content

Latest commit

 

History

History
159 lines (132 loc) · 5.1 KB

Module Example.md

File metadata and controls

159 lines (132 loc) · 5.1 KB

Module Example

File Structure

⠀〰️ 📁 /modules

⠀⠀⠀⠀〰️ 📁/<name>

⠀⠀⠀⠀⠀⠀⠀⠀〰️ 📁/languages

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀📄 <code>.po⠀⠀⠀⠀⠀⠀⠀⠀(For example en_US.po)

⠀⠀⠀⠀⠀⠀⠀⠀〰️ 📁/setup

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀📄 install.php

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀📄 deinstall.php

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀📄 check.php

⠀⠀⠀⠀⠀⠀⠀📄 module.package

⠀⠀⠀⠀⠀⠀⠀📄 daemon.php

⠀⠀⠀⠀⠀⠀⠀📄 module.php

⠀⠀⠀⠀⠀⠀⠀📄 CHANGELOG.md⠀⠀⠀⠀⠀ Optional

⠀⠀⠀⠀⠀⠀⠀📄 README.md⠀⠀⠀⠀⠀⠀⠀⠀Optional

module.package

{
	"name":			"ExampleModule",
	"version":		"1.0.0",
	"category":		<NavigationCategory>,
	"icon":			<NavigationIcon>,
	"order":		<NavigationOrder>,
	"permissions":		<Permissions>,
	"description":	"This is an description.",
	"author":		{
		"name":		"Your Name",
		"email":	<email>,
		"url":		<url>
	},
	"repository":	<github-url>,
	"screenshots": [
		{
			"file": <image>
			"description": "Screenshost description"
		}
	]
}

Possible Values

<NavigationCategory> string Possible values: ACCOUNT_MANAGEMENT, DATABASE_MANAGEMENT, DOMAIN_MANAGEMENT, MAIL_MANAGEMENT, FTP_MANAGEMENT, HOSTING_MANAGEMENT, EXTENDED_MANAGEMENT, SUPPORT_MANAGEMENT, ADMIN_MANAGEMENT, SERVER_MANAGEMENT
<NavigationIcon> string A name of an Material Icon
<NavigationOrder> int The position of the module in the navigation
<Permissions> array A list of Permissions that are allowed to see the module.

module.php

<?php
	use fruithost\ModuleInterface;

	class ExampleModule extends ModuleInterface {
		/* System Callbacks */
			public function init() : void {
				/*
	                		Is called up when the module is initialized by the module manager.
	
	               			Not all methods are available at this point and there is no guarantee that another module is already accessible here.
	            		*/
			}
			
	        	public function preLoad() : void {
				/*
	                		Is called up shortly before the module is actively used.
	            		*/
			}
	
			public function load() : void {
				/*
	                		Is called up as soon as the module is actively used (for example by calling it up via the menu).
	            		*/
			}

		/* Displaying Contents */
			public function frame() : ?string {
				/*
	                		The URL of an Frame of the module that is displayed in the UI.
					For a simple sample: If you want to display external Services like PHPMyAdmin or a Webmailer on the Panel.
	            		*/
	
				return 'https://example.com/phpmyadmin';
			}
			
			public function content() {
				/*
	                		The content of the module that is displayed/output in the UI.
	            		*/
			}

		/* Handling Requests or Data */
			public function onPOST($data = []) : void {
				/*
	                		This is called when a POST request is fired on the module page.
	           		*/
			}
	}
?>

setup/install.php & setup/deinstall.php

A PHP file that is used/called as soon as the module is installed or uninstalled by the system administrator. Database operations can be carried out here, for example.

Note

Currently, these files are executed with the rights of the webserver with www-data-user. If you want to execute these scripts with extended rights (root), take a look at Module Permissions.

To install the module, enter the following command via Shell:

fruithost install

To uninstall the module, enter the following command via Shell:

fruithost deinstall

A module can be activated with the following command:

fruithost enable

or deactivated:

fruithost disable

setup/check.php

Since Panel-Version 1.0.3, modules can have a self-check. For this purpose, module-related tests are carried out in setup/check.php. If no output is generated by the checks, the module has been checked correctly. If the self-check is to generate errors, only output must be generated.

Sample Check:

<?php
	use fruithost\Storage\Database;
	
	if(!Database::tableExists(DATABASE_PREFIX . 'certificates')) {
		print('Table <strong>certificates</strong> not exists!');
	}
?>

CHECK

daemon.php

This file is called up by the Daemon every minute. Batch processing that does not take place in the user's UI can take place here, for example.

Note

Currently, these files are executed with the rights of the webserver with www-data-user. If you want to execute these scripts with extended rights (root), take a look at Module Permissions.