<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Add apply button on 2.3 pkg xml framework]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Since dansguardian package on 2.x, I've implemented the 'apply changes' on packages using pkg framework.</p>
<p dir="auto">After bootstrap move on 2.3, in order to get the same functionality I've started using functions <strong>mark_subsystem_dirty</strong>, <strong>check_subsystem_drity</strong>, etc.</p>
<p dir="auto">The procedure below shows how to add this function to any package gui based on pkg framework.</p>
<p dir="auto"><strong>On each package xml file, add a function call to check dirty state.</strong></p>
<pre><code>
        &lt;custom_php_resync_config_command&gt;sync_package_e2guardian();&lt;/custom_php_resync_config_command&gt; 

       &lt;custom_php_command_before_form&gt;e2guardian_check_config();&lt;/custom_php_command_before_form&gt; 

</code></pre>
<p dir="auto"><strong>On package.inc file, create the check config state function</strong></p>
<pre><code>
function e2guardian_check_config() {
        global $savemsg, $config;

        if (!isset($config['installedpackages']['e2guardian']['config'][0]['enable'])) {
                return 1;
        }

        if (isset($_REQUEST['apply'])) {
                e2guardian_start("no", false, true);
                return;
        }
        if (is_subsystem_dirty('e2guardian')) {
                $savemsg  = gettext("E2guardian configuration has been changed.") . "
" . gettext("The changes must be applied for them to take effect.");
                $savemsg .= "&lt;a&gt;  &lt;/a&gt;";
       }

        return 0;
}

**On the place you call the code to write files and/or restart the service, replace it with mark_subsystem_dirty('your_package')**
</code></pre>
<p dir="auto">function sync_package_e2guardian($via_rpc = "no", $install_process = false) {<br />
        global $config, $g;<br />
.<br />
.  /<em>all code stuff and checks...</em>/<br />
.<br />
//mark config changes<br />
mark_subsystem_dirty('e2guardian');<br />
}</p>
<pre><code>
**Under the function you created to separate save from apply changes on your package inc file, clean the 'dirty' state**
</code></pre>
<p dir="auto">function e2guardian_start($via_rpc = "no", $install_process = false, $force_start = false) {<br />
        global $g, $config, $savemsg;</p>
<p dir="auto">clear_subsystem_dirty('e2guardian');<br />
.<br />
.<br />
.</p>
<pre><code>
The image attached shows the result.
![e2guardian_apply_button.PNG_thumb](/public/_imported_attachments_/1/e2guardian_apply_button.PNG_thumb)
![e2guardian_apply_button.PNG](/public/_imported_attachments_/1/e2guardian_apply_button.PNG)
</code></pre>
]]></description><link>https://forum.netgate.com/topic/113745/add-apply-button-on-2-3-pkg-xml-framework</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 20:09:15 GMT</lastBuildDate><atom:link href="https://forum.netgate.com/topic/113745.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 Mar 2017 15:29:20 GMT</pubDate><ttl>60</ttl></channel></rss>