Extensions to server.php

Discussion in 'Developers' Forum' started by jwarnier, Aug 13, 2010.

  1. jwarnier

    jwarnier ISPConfig Developer ISPConfig Developer

    We (BeezNest) felt the need for some extension mechanism (plugins) to server.php. To be more specific, being able to add features to it without having to modify server.php itself, like installing web applications automatically on a site.
    So we implemented a function to add to server.php to load php files from a server/server.d directory, not unlike the /etc/apache2/conf.d/ directory, which is loaded by Apache and where you can drop "extensions" like aliases to web applications.

    Would this be considered as a good addition to ISPconfig or not?
  2. falko

    falko Super Moderator ISPConfig Developer

    Unfortunately Till, the main developer, is off for holidays (the first for years :)); he'll be back in a week and will be able to answer this question.
  3. jwarnier

    jwarnier ISPConfig Developer ISPConfig Developer

    No problem, we just added a require line to another script which does this in our local copy. I think it could be a good addition to ISPconfig, but not being able to merge this for one week is certainly not disturbing.

    Thanks for you answer.
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig has aleady a mechanism for it, it is named plugins and modules. Why havent you implemented this as module or plugin? I dont think that it is a wise decision to duplicate the functionality.
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Here is some short code on how to use the ispconfig module system to execute your code everytime the server.php file is executed without the need of creating a second include system.

    1) Add new file with the name my_core_module.inc.php in server/mods-available. The content can be e.g. like this:

    class my_core_module {
    	var $module_name = 'my_core_module';
    	var $class_name = 'my_core_module';
    	//* This function is called during ispconfig installation to determine
    	//  if a symlink shall be created for this plugin.
    	function onInstall() {
    		global $conf;
    		return true;
            This function is called when the module is loaded
    	function onLoad() {
    		global $app;
    		//* Do something here
    Then add a symlink from server/mods-core/my_core_module.inc.php to server/mods-available/my_core_module.inc.php

    Add your custom code below the line "//* Do something here". Such a module should only be used if you do not have added any database tables for the functions that you implemented or these tables are not connected to forms in the interface.

    If you use forms in the intrefcae and database tables, then create a normal "non core" module like the server_module or web_module together with events and then add your functionality to a custom plugin that runs event based like all other plugins in the ispconfig server part.
    Last edited: Aug 23, 2010
  6. jwarnier

    jwarnier ISPConfig Developer ISPConfig Developer

    Yes, you are right. We have been stupid in introducing yet another system while there was already one in place.
    We will convert ours to a plugin.

    We were using this to automatically install a web application to a hosting.
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Thanks, that would be great! If you feel that a specific feature is missing in the current plugin / module system to implement your web app installer, please let me know so we can discuss on how to extend the plugin system.
  8. jwarnier

    jwarnier ISPConfig Developer ISPConfig Developer

    We will, no doubt. Thanks for your offering you assistance.

    Please note that it is already working using our duplicate "plugin" system for a custom-made installation of Chamilo (an Open Source e-learning platform).

Share This Page