<packagegui>
	<name>siproxdusers</name>
	<version>0.5.9</version>
	<title>siproxd: Users</title>
	<tabs>
		<tab>
			<text>Settings</text>
			<url>/pkg_edit.php?xml=siproxd.xml&amp;id=0</url>
		</tab>
		<tab>
			<text>Users</text>
			<url>/pkg.php?xml=siproxdusers.xml</url>
			<active/>
		</tab>
	</tabs>
	<configpath>installedpackages->package->$packagename->configuration->settings</configpath>
	<adddeleteeditpagefields>
		<columnitem>
			<fielddescr>Username</fielddescr>
			<fieldname>username</fieldname>
		</columnitem>
		<columnitem>
			<fielddescr>Description</fielddescr>
			<fieldname>description</fieldname>
		</columnitem>
	</adddeleteeditpagefields>
	<fields>
		<field>
			<fielddescr>Username</fielddescr>
			<fieldname>username</fieldname>
			<description>Enter the username here</description>
			<type>input</type>
		</field>
		<field>
			<fielddescr>Password</fielddescr>
			<fieldname>password</fieldname>
			<description>Enter the password here</description>
			<type>password</type>
		</field>
		<field>
			<fielddescr>Username Description</fielddescr>
			<fieldname>description</fieldname>
			<description>Enter the description of the user here</description>
			<type>input</type>
		</field>
	</fields>
	<custom_php_resync_config_command>
	    sync_package_sipproxd_users();
	</custom_php_resync_config_command>
	<custom_add_php_command>
		function sync_package_sipproxd_users()
		{
			conf_mount_rw();
			config_lock();
			global $config;
			$fout = fopen("/usr/local/etc/siproxd_passwd.cfg","w");
			fwrite($fout, "# This file was automatically generated by the pfSense\n# package management system.\n\n");
			if($config['installedpackages']['siproxdusers']['config'] != "") {
				foreach($config['installedpackages']['siproxdusers']['config'] as $rowhelper) {
					fwrite($fout, $rowhelper['username'] . " " . $rowhelper['password'] . "\n");
				}
			}
		 	fclose($fout);
			conf_mount_ro();
			config_unlock();
			system("/usr/bin/killall -HUP siproxd");
		}
		sync_package_sipproxd_users();
	</custom_add_php_command>
</packagegui>