Our task is to add the checkbox "1C-Bitrix" on the domain edit form. Depending on the checkbox status, the configuration file Apache will contain different values for the directive open_basedir:
- the checkbox is selected — open_basedir is "none";
- the checkbox is not selected — the open_basedir value equals the domain home directory.
Usually a plug-in consists of the XML file that describes the plug-in and where you can add/hide interface elements, and a handler. The handler is a script that will be called before or after a certain action of the control panel. Add the XML to the directory /usr/local/mgr5/etc/xml/ and name it as ispmgr_mod_<name>.xml, eg. /usr/local/mgr5/etc/xml/ispmgr_mod_bitrix.xml
The XML file must have read/write permissions for the root user.
XML description of the plug-in
The metadata section describes that a new field (name="bitrix") of the checkbox type (type="checkbox") will be added to the WWW-domain tab (page name="domain") on the edit form (type="form") of the web domain (name="webdomain.edit")
The handler section describes that after (after="yes") the web domain is edited (webdomain.edit) the script named bitrix (handler name="bitrix") of the xml type (type="xml") will be called.
The type xml means that the script receives the XML file with parameters to stdin from the control panel. The plug-in must return the same XML to stdout where custom parameters can be added or existing parameters can be modified.
The lang section defines description and a hint in the Russian and English languages.
After you have added the custom xml, restart the control panel
Add the handler script to the directory /usr/local/mgr5/addon . The file must have the same name as it is specified in the handler section of the xml. In our example, this is the file /usr/local/mgr5/addon/bitrix:
Set permissions for the handler with the following commands:
chmod 750 /usr/local/mgr5/addon/<handler_file_name> chown 0:0 /usr/local/mgr5/addon/<handler_file_name>
The value of the variable $PARAM_bitrix is checked in the condition. The control panel sends some parameters to the environment variables and they can be used in the plug-in handler. $PARAM_bitrix is the variable that can be on, if the checkbox "1C-Bitrix" is selected on the domain edit form and can be off, if the checkbox is not selected.
The plug-in sends to the control panel the same xml file that it has received to stdin, but it adds its custom parameter CUSTOM_BASEDIR to the xml. This parameter can have the value none, if the checkbox "1C-Bitrix" is selected or <domain home directory>, if the checkbox is not selected.
Finally, edit the template engine file that will define what directives will be specified in the configuration file Apache.
In the file /usr/local/mgr5/etc/templates/apache2-vhosts.template change
Now the value open_basedir will be defined by the variable CUSTOM_BASEDIR that we add with the plug-in and define its value ourselves depending on the checkbox "1C-Bitrix" on the domain edit form.