diff --git a/web/includes/actions.php b/web/includes/actions.php
index b00328d9f..bed4831f7 100644
--- a/web/includes/actions.php
+++ b/web/includes/actions.php
@@ -372,11 +372,14 @@ if ( !empty($action) )
$changes=0;
foreach( $pconfs as $pconf )
{
- $value=$_REQUEST['pluginOpt'][$pconf['Name']];
- if(array_key_exists($pconf['Name'], $_REQUEST['pluginOpt']) && ($pconf['Value']!=$value))
+ if(isset($_REQUEST['pluginOpt'][$pconf['Name']]))
{
- dbQuery("UPDATE PluginsConfig SET Value=? WHERE id=?", array( $value, $pconf['Id'] ) );
- $changes++;
+ $value=$_REQUEST['pluginOpt'][$pconf['Name']];
+ if(array_key_exists($pconf['Name'], $_REQUEST['pluginOpt']) && ($pconf['Value']!=$value))
+ {
+ dbQuery("UPDATE PluginsConfig SET Value=? WHERE id=?", array( $value, $pconf['Id'] ) );
+ $changes++;
+ }
}
}
if($changes>0)
@@ -409,6 +412,7 @@ if ( !empty($action) )
foreach( $_REQUEST['markZids'] as $markZid )
{
dbQuery( "delete from Zones WHERE MonitorId=? AND Id=?", array( $mid, $markZid) );
+ dbQuery( "delete from PluginsConfig WHERE MonitorId=? AND ZoneId=?", array( $mid, $markZid) );
$deletedZid = 1;
}
if ( $deletedZid )
@@ -593,6 +597,7 @@ if ( !empty($action) )
// This is the important stuff
dbQuery( "delete from Monitors where Id = ?", array($markMid) );
dbQuery( "delete from Zones where MonitorId = ?", array($markMid) );
+ dbQuery( "delete from PluginsConfig where MonitorId = ?", array($markMid) );
if ( ZM_OPT_X10 )
dbQuery( "delete from TriggersX10 where MonitorId=?", array($markMid) );
diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js
index b09a646da..4ccecbeee 100644
--- a/web/skins/classic/js/skin.js
+++ b/web/skins/classic/js/skin.js
@@ -55,6 +55,7 @@ var popupSizes = {
'montage': { 'width': -1, 'height': -1 },
'optionhelp': { 'width': 400, 'height': 320 },
'options': { 'width': 1000, 'height': 660 },
+ 'plugin': { 'addWidth': 16, 'addHeight': 48 },
'preset': { 'width': 300, 'height': 120 },
'settings': { 'width': 220, 'height': 225 },
'state': { 'width': 370, 'height': 134 },
diff --git a/web/skins/classic/views/Makefile.am b/web/skins/classic/views/Makefile.am
index 58c72b78f..ef71878ca 100644
--- a/web/skins/classic/views/Makefile.am
+++ b/web/skins/classic/views/Makefile.am
@@ -41,6 +41,7 @@ dist_web_DATA = \
none.php \
optionhelp.php \
options.php \
+ plugin.php \
postlogin.php \
settings.php \
state.php \
diff --git a/web/skins/classic/views/css/Makefile.am b/web/skins/classic/views/css/Makefile.am
index 39c270cf7..ffdb11449 100644
--- a/web/skins/classic/views/css/Makefile.am
+++ b/web/skins/classic/views/css/Makefile.am
@@ -23,6 +23,7 @@ dist_web_DATA = \
montage.css \
montage_freeform.css \
options.css \
+ plugin.css \
stats.css \
timeline.css \
timeline.css.php \
diff --git a/web/skins/classic/views/css/plugin.css b/web/skins/classic/views/css/plugin.css
index 040e26558..1490026fc 100644
--- a/web/skins/classic/views/css/plugin.css
+++ b/web/skins/classic/views/css/plugin.css
@@ -3,6 +3,10 @@
margin: 0 2px;
}
+#settingsPanel input[type=submit] {
+ margin: 8px 4px;
+}
+
#pluginSettings {
border-collapse: collapse;
}
diff --git a/web/skins/classic/views/css/zone.css b/web/skins/classic/views/css/zone.css
index 2f6754275..f0a4a819f 100644
--- a/web/skins/classic/views/css/zone.css
+++ b/web/skins/classic/views/css/zone.css
@@ -93,3 +93,22 @@
#zonePoints table a {
margin: 0 2px;
}
+
+a.pluginNotEnabled {
+ text-decoration: none;
+ color: grey;
+}
+
+a.pluginError {
+ text-decoration: none;
+ color: red;
+}
+
+a.pluginNotActive {
+ color: orange;
+}
+
+a.pluginActive {
+ color: green;
+}
+
diff --git a/web/skins/classic/views/js/Makefile.am b/web/skins/classic/views/js/Makefile.am
index ba1845e0c..19acd4716 100644
--- a/web/skins/classic/views/js/Makefile.am
+++ b/web/skins/classic/views/js/Makefile.am
@@ -33,6 +33,8 @@ dist_web_DATA = \
montage.js \
montage.js.php \
options.js.php \
+ plugin.js \
+ plugin.js.php \
postlogin.js \
state.js \
state.js.php \
diff --git a/web/skins/classic/views/js/plugin.js b/web/skins/classic/views/js/plugin.js
index f03768317..54d39a872 100644
--- a/web/skins/classic/views/js/plugin.js
+++ b/web/skins/classic/views/js/plugin.js
@@ -5,9 +5,49 @@ function validateForm( form )
function submitForm( form )
{
+ var cb = form.getElementsByTagName('input');
+ for ( var i = 0; i < cb.length; i++)
+ {
+ if ( cb[i].type == 'checkbox' && !cb[i].checked ) // if this is an unchecked checkbox
+ {
+ cb[i].value = 0; // set the value to "off"
+ cb[i].checked = true; // make sure it submits
+ }
+ }
form.submit();
}
+function saveChanges( element )
+{
+ var form = element.form;
+ if ( validateForm( form ) )
+ {
+ submitForm( form );
+ return( true );
+ }
+ return( false );
+}
+
+function applyDependencies()
+{
+ var form = document.pluginForm;
+ for ( var option in dependencies )
+ {
+ var enabled = true;
+ for ( var name in dependencies[option] )
+ {
+ if (form.elements['pluginOpt[' + name + ']'].value != dependencies[option][name])
+ {
+ form.elements['pluginOpt[' + option + ']'].disabled = true;
+ enabled = false;
+ break;
+ }
+
+ }
+ if (enabled)
+ form.elements['pluginOpt[' + option + ']'].disabled = false;
+ }
+}
function limitRange( field, minValue, maxValue )
{
diff --git a/web/skins/classic/views/js/plugin.js.php b/web/skins/classic/views/js/plugin.js.php
index e69de29bb..d07a5e0b8 100644
--- a/web/skins/classic/views/js/plugin.js.php
+++ b/web/skins/classic/views/js/plugin.js.php
@@ -0,0 +1,17 @@
+var dependencies = {};
+
+dependencies['= $option['Name'] ?>'] = {};
+
+dependencies['= $option['Name'] ?>']['= $req_couple['Name'] ?>'] = '= $req_couple['Value'] ?>';
+
diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php
index 5115c74a7..d238f6190 100644
--- a/web/skins/classic/views/monitor.php
+++ b/web/skins/classic/views/monitor.php
@@ -106,6 +106,7 @@ if ( ! empty($_REQUEST['mid']) ) {
'Triggers' => "",
'V4LMultiBuffer' => '',
'V4LCapturesPerFrame' => 1,
+ 'DoNativeMotDet' => true
);
}
@@ -471,6 +472,7 @@ if ( $tab != 'general' )
+
+
= $SLANG['DoNativeMotionDetection'] ?> | checked="checked"/> |
= $SLANG['Triggers'] ?> |
0 ) {
$monitor = dbFetchMonitor ( $mid );
$plugin = $_REQUEST['pl'];
-$plugin_path = dirname(ZM_PLUGINS_CONFIG_PATH)."/".$plugin;
+$plugin_path = dirname($_SERVER['SCRIPT_FILENAME'])."/plugins/".$plugin;
$focusWindow = true;
-xhtmlHeaders(__FILE__, $SLANG['Plugin'] );
-
-
-$pluginOptions=array(
- 'Enabled'=>array(
- 'Type'=>'select',
- 'Name'=>'Enabled',
- 'Choices'=>'yes,no',
- 'Value'=>'no'
- )
- );
+$generalOptions=array(
+ 'Enabled'=>array(
+ 'Type'=>'select',
+ 'Name'=>'Enabled',
+ 'Choices'=>'Yes,No',
+ 'Value'=>'No'
+ ),
+ 'RequireNatDet'=>array(
+ 'Type'=>'select',
+ 'Name'=>'RequireNatDet',
+ 'Choices'=>'Yes,No',
+ 'Value'=>'No',
+ 'Require'=>array(
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ )
+ )
+ ),
+ 'IncludeNatDet'=>array(
+ 'Type'=>'select',
+ 'Name'=>'IncludeNatDet',
+ 'Choices'=>'Yes,No',
+ 'Value'=>'No',
+ 'Require'=>array(
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ ),
+ array(
+ 'Name'=>'RequireNatDet',
+ 'Value'=>'Yes'
+ )
+ )
+ ),
+ 'ReInitNatDet'=>array(
+ 'Type'=>'select',
+ 'Name'=>'ReInitNatDet',
+ 'Choices'=>'Yes,No',
+ 'Value'=>'No',
+ 'Require'=>array(
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ ),
+ array(
+ 'Name'=>'RequireNatDet',
+ 'Value'=>'Yes'
+ )
+ )
+ ),
+ 'AlarmeScore'=>array(
+ 'Type'=>'integer',
+ 'Name'=>'AlarmeScore',
+ 'Min'=>'1',
+ 'Max'=>'100',
+ 'Value'=>'99',
+ 'Require'=>array(
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ )
+ )
+ )
+);
+$options=$generalOptions;
$optionNames=array();
if(file_exists($plugin_path."/config.php"))
{
include_once($plugin_path."/config.php");
-}
+ if(isset($pluginOptions))
+ foreach( $pluginOptions as $optionKey => $optionValue )
+ {
+ // Set default dependency information if not set in configuration file
+ if(!isset($optionValue['Require']))
+ $optionValue['Require'] = array (
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ )
+ );
+ $options[$optionKey]=$optionValue;
+ }
+}
$sql='SELECT * FROM PluginsConfig WHERE MonitorId=? AND ZoneId=? AND pluginName=?';
foreach( dbFetchAll( $sql, NULL, array( $mid, $zid, $plugin ) ) as $popt )
{
- if(array_key_exists($popt['Name'], $pluginOptions)
- && $popt['Type']==$pluginOptions[$popt['Name']]['Type']
- && $popt['Choices']==$pluginOptions[$popt['Name']]['Choices']
- )
+ if(array_key_exists($popt['Name'], $options)
+ && $popt['Type']==$options[$popt['Name']]['Type'])
{
- $pluginOptions[$popt['Name']]=$popt;
array_push($optionNames, $popt['Name']);
+
+ // Backup dependency information
+ $require = '';
+ if(isset($options[$popt['Name']]['Require']))
+ $require = $options[$popt['Name']]['Require'];
+
+ // Set value from database
+ $options[$popt['Name']]=$popt;
+
+ // Restore dependancy information from backup
+ if(!empty($require))
+ $options[$popt['Name']]['Require'] = $require;
+
+ // Set default dependancy information if not set in configuration
+ else if($popt['Name'] != 'Enabled')
+ $options[$popt['Name']]['Require'] = array (
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ )
+ );
} else {
dbQuery('DELETE FROM PluginsConfig WHERE Id=?', array( $popt['Id'] ) );
}
}
-foreach($pluginOptions as $name => $values)
+
+foreach($options as $name => $values)
{
if(!in_array($name, $optionNames))
{
- $popt=$pluginOptions[$name];
- $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,?,?,?,?)";
- dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Choices'], $mid, $zid, $plugin ) );
+ $popt=$options[$name];
+ switch($popt['Type'])
+ {
+ case "select":
+ $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,?,'','',?,?,?)";
+ dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Choices'], $mid, $zid, $plugin ) );
+ break;
+ case "integer":
+ $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,'',?,?,?,?,?)";
+ dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Min'], $popt['Max'], $mid, $zid, $plugin ) );
+ break;
+ case "checkbox":
+ case "text":
+ default:
+ $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,'','','',?,?,?)";
+ dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $mid, $zid, $plugin ) );
+ }
}
}
$PLANG=array();
-if(file_exists($plugin_path."/lang/".$user['Language'].".php")) {
- include_once($plugin_path."/lang/".$user['Language'].".php");
+$lang_path = $plugin_path."/lang";
+$userLangFile = $lang_path."/".$user['Language'].".php";
+if (isset($user['Language']) && file_exists($userLangFile)) {
+ include_once($userLangFile);
+} else {
+ $systemLangFile = $lang_path."/".ZM_LANG_DEFAULT.".php";
+ if (file_exists($systemLangFile)) {
+ include_once($systemLangFile);
+ } else {
+ $fallbackLangFile = $lang_path."/en_gb.php";
+ if (file_exists($fallbackLangFile)) {
+ include_once($fallbackLangFile);
+ }
+ }
}
function pLang($name)
{
+ global $SLANG;
global $PLANG;
- if(array_key_exists($name, $PLANG))
+ if(array_key_exists($name, $SLANG))
+ return $SLANG[$name];
+ else if(array_key_exists($name, $PLANG))
return $PLANG[$name];
else
return $name;
}
+function isEnabled($param)
+{
+ global $options;
+ $option = $options[$param];
+ if (!isset($option['Require']))
+ return true;
+ foreach($option['Require'] as $req_couple)
+ {
+ $name = $req_couple['Name'];
+ if (!array_key_exists($name, $options))
+ continue;
+ if ($req_couple['Value'] != $options[$name]['Value'])
+ return false;
+ }
+ return true;
+}
+xhtmlHeaders(__FILE__, $SLANG['Plugin'] );
?>
@@ -117,21 +250,23 @@ function pLang($name)
-foreach($pluginOptions as $name => $popt)
+foreach($options as $name => $popt)
{
- ?>
- = pLang($name) ?> |
-
+?>
+
---|
= pLang($name) ?> |
+
switch($popt['Type'])
{
case "checkbox":
- echo "CHECKBOX";
+ ?>
+ > |
+
break;
case "select":
$pchoices=explode(',',$popt['Choices']);
?>
- |
+
break;
case "text":
+ ?>
+ > |
+
+ break;
+ case "integer":
+ ?>
+ > |
+
+ break;
default:
- echo "DEFAULT";
+ echo "Type '".$popt['Type']."' is not implemented ";
}
?>
diff --git a/web/skins/classic/views/zone.php b/web/skins/classic/views/zone.php
index 822e1b315..217f34012 100644
--- a/web/skins/classic/views/zone.php
+++ b/web/skins/classic/views/zone.php
@@ -212,6 +212,60 @@ xhtmlHeaders(__FILE__, $SLANG['Zone'] );
= $SLANG['ZoneExtendAlarmFrames'] ?> |
|
+ 0)
+{
+ // Get plugin status from zmu command line
+ exec(escapeshellcmd(getZmuCommand(" -p -m".$mid)), $cmdOutput, $retval);
+ if($retval == 0)
+ {
+ echo "".$SLANG['Plugins']." | \n";
+ $plName = "";
+ $plReg = "0";
+ $plConf = "0";
+ foreach($cmdOutput as $key => $line)
+ {
+ // Skip header lines or "No plugin found"
+ if($key < 2) continue;
+ // Parse line
+ $pl = preg_split ('/[\s]+/ ', trim($line));
+ $offset = 0;
+ if(sizeof($pl) == 9)
+ {
+ $plName = $pl[0];
+ $plReg = $pl[1];
+ $plConf = $pl[2];
+ $offset = 3;
+ }
+ // Skip line if zone mismatch
+ if($pl[$offset] != $zid) continue;
+ // Select class and set display setting
+ $class = '';
+ $dspPlConf = true;
+ if(!ZM_LOAD_PLUGINS) {
+ $class = " class=\"pluginNotEnabled\"";
+ $dspPlConf = false;
+ } else if($plReg == "0" || (($plReg == "1") && ($plConf == "0"))) {
+ $class = " class=\"pluginError\"";
+ $dspPlConf = false;
+ } else if(($pl[1 + $offset] == "1") && ($pl[2 + $offset] == "0")) {
+ $class = " class=\"pluginNotActive\"";
+ } else if($pl[2 + $offset] == "1") {
+ $class = " class=\"pluginActive\"";
+ }
+ // Display plugin name and enable link
+ if($dspPlConf)
+ echo "".$plName." \n";
+ else
+ echo "".$plName." \n";
+ }
+ echo " | \n";
+ }
+}
+?>
diff --git a/web/skins/flat/js/skin.js b/web/skins/flat/js/skin.js
index cc1476a9a..5bc77e607 100644
--- a/web/skins/flat/js/skin.js
+++ b/web/skins/flat/js/skin.js
@@ -55,6 +55,7 @@ var popupSizes = {
'montage': { 'width': -1, 'height': -1 },
'optionhelp': { 'width': 400, 'height': 320 },
'options': { 'width': 1370, 'height': 620 },
+ 'plugin': { 'addWidth': 16, 'addHeight': 48 },
'preset': { 'width': 300, 'height': 120 },
'settings': { 'width': 200, 'height': 225 },
'state': { 'width': 400, 'height': 154 },
diff --git a/web/skins/flat/views/Makefile.am b/web/skins/flat/views/Makefile.am
index 84b6b9811..d55f35a68 100644
--- a/web/skins/flat/views/Makefile.am
+++ b/web/skins/flat/views/Makefile.am
@@ -41,6 +41,7 @@ dist_web_DATA = \
none.php \
optionhelp.php \
options.php \
+ plugin.php \
postlogin.php \
settings.php \
state.php \
diff --git a/web/skins/flat/views/css/Makefile.am b/web/skins/flat/views/css/Makefile.am
index 3e0ef100b..3528469ad 100644
--- a/web/skins/flat/views/css/Makefile.am
+++ b/web/skins/flat/views/css/Makefile.am
@@ -23,6 +23,7 @@ dist_web_DATA = \
montage.css \
montage_freeform.css \
options.css \
+ plugin.css \
stats.css \
timeline.css \
timeline.css.php \
diff --git a/web/skins/flat/views/css/plugin.css b/web/skins/flat/views/css/plugin.css
index 040e26558..1490026fc 100644
--- a/web/skins/flat/views/css/plugin.css
+++ b/web/skins/flat/views/css/plugin.css
@@ -3,6 +3,10 @@
margin: 0 2px;
}
+#settingsPanel input[type=submit] {
+ margin: 8px 4px;
+}
+
#pluginSettings {
border-collapse: collapse;
}
diff --git a/web/skins/flat/views/css/zone.css b/web/skins/flat/views/css/zone.css
index 2f6754275..f0a4a819f 100644
--- a/web/skins/flat/views/css/zone.css
+++ b/web/skins/flat/views/css/zone.css
@@ -93,3 +93,22 @@
#zonePoints table a {
margin: 0 2px;
}
+
+a.pluginNotEnabled {
+ text-decoration: none;
+ color: grey;
+}
+
+a.pluginError {
+ text-decoration: none;
+ color: red;
+}
+
+a.pluginNotActive {
+ color: orange;
+}
+
+a.pluginActive {
+ color: green;
+}
+
diff --git a/web/skins/flat/views/js/Makefile.am b/web/skins/flat/views/js/Makefile.am
index 2b2c1a53d..6b115a8d9 100644
--- a/web/skins/flat/views/js/Makefile.am
+++ b/web/skins/flat/views/js/Makefile.am
@@ -33,6 +33,8 @@ dist_web_DATA = \
montage.js \
montage.js.php \
options.js.php \
+ plugin.js \
+ plugin.js.php \
postlogin.js \
state.js \
state.js.php \
diff --git a/web/skins/flat/views/js/plugin.js b/web/skins/flat/views/js/plugin.js
index f03768317..54d39a872 100644
--- a/web/skins/flat/views/js/plugin.js
+++ b/web/skins/flat/views/js/plugin.js
@@ -5,9 +5,49 @@ function validateForm( form )
function submitForm( form )
{
+ var cb = form.getElementsByTagName('input');
+ for ( var i = 0; i < cb.length; i++)
+ {
+ if ( cb[i].type == 'checkbox' && !cb[i].checked ) // if this is an unchecked checkbox
+ {
+ cb[i].value = 0; // set the value to "off"
+ cb[i].checked = true; // make sure it submits
+ }
+ }
form.submit();
}
+function saveChanges( element )
+{
+ var form = element.form;
+ if ( validateForm( form ) )
+ {
+ submitForm( form );
+ return( true );
+ }
+ return( false );
+}
+
+function applyDependencies()
+{
+ var form = document.pluginForm;
+ for ( var option in dependencies )
+ {
+ var enabled = true;
+ for ( var name in dependencies[option] )
+ {
+ if (form.elements['pluginOpt[' + name + ']'].value != dependencies[option][name])
+ {
+ form.elements['pluginOpt[' + option + ']'].disabled = true;
+ enabled = false;
+ break;
+ }
+
+ }
+ if (enabled)
+ form.elements['pluginOpt[' + option + ']'].disabled = false;
+ }
+}
function limitRange( field, minValue, maxValue )
{
diff --git a/web/skins/flat/views/js/plugin.js.php b/web/skins/flat/views/js/plugin.js.php
index e69de29bb..d07a5e0b8 100644
--- a/web/skins/flat/views/js/plugin.js.php
+++ b/web/skins/flat/views/js/plugin.js.php
@@ -0,0 +1,17 @@
+var dependencies = {};
+
+dependencies['= $option['Name'] ?>'] = {};
+
+dependencies['= $option['Name'] ?>']['= $req_couple['Name'] ?>'] = '= $req_couple['Value'] ?>';
+
diff --git a/web/skins/flat/views/monitor.php b/web/skins/flat/views/monitor.php
index 6eeec11cc..970c92474 100644
--- a/web/skins/flat/views/monitor.php
+++ b/web/skins/flat/views/monitor.php
@@ -106,6 +106,7 @@ if ( ! empty($_REQUEST['mid']) ) {
'Triggers' => "",
'V4LMultiBuffer' => '',
'V4LCapturesPerFrame' => 1,
+ 'DoNativeMotDet' => true
);
}
@@ -471,6 +472,7 @@ if ( $tab != 'general' )
+
+ |
= $SLANG['DoNativeMotionDetection'] ?> | checked="checked"/> |
= $SLANG['Triggers'] ?> |
0 ) {
$monitor = dbFetchMonitor ( $mid );
$plugin = $_REQUEST['pl'];
-$plugin_path = dirname(ZM_PLUGINS_CONFIG_PATH)."/".$plugin;
+$plugin_path = dirname($_SERVER['SCRIPT_FILENAME'])."/plugins/".$plugin;
$focusWindow = true;
-xhtmlHeaders(__FILE__, $SLANG['Plugin'] );
-
-
-$pluginOptions=array(
- 'Enabled'=>array(
- 'Type'=>'select',
- 'Name'=>'Enabled',
- 'Choices'=>'yes,no',
- 'Value'=>'no'
- )
- );
+$generalOptions=array(
+ 'Enabled'=>array(
+ 'Type'=>'select',
+ 'Name'=>'Enabled',
+ 'Choices'=>'Yes,No',
+ 'Value'=>'No'
+ ),
+ 'RequireNatDet'=>array(
+ 'Type'=>'select',
+ 'Name'=>'RequireNatDet',
+ 'Choices'=>'Yes,No',
+ 'Value'=>'No',
+ 'Require'=>array(
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ )
+ )
+ ),
+ 'IncludeNatDet'=>array(
+ 'Type'=>'select',
+ 'Name'=>'IncludeNatDet',
+ 'Choices'=>'Yes,No',
+ 'Value'=>'No',
+ 'Require'=>array(
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ ),
+ array(
+ 'Name'=>'RequireNatDet',
+ 'Value'=>'Yes'
+ )
+ )
+ ),
+ 'ReInitNatDet'=>array(
+ 'Type'=>'select',
+ 'Name'=>'ReInitNatDet',
+ 'Choices'=>'Yes,No',
+ 'Value'=>'No',
+ 'Require'=>array(
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ ),
+ array(
+ 'Name'=>'RequireNatDet',
+ 'Value'=>'Yes'
+ )
+ )
+ ),
+ 'AlarmeScore'=>array(
+ 'Type'=>'integer',
+ 'Name'=>'AlarmeScore',
+ 'Min'=>'1',
+ 'Max'=>'100',
+ 'Value'=>'99',
+ 'Require'=>array(
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ )
+ )
+ )
+);
+$options=$generalOptions;
$optionNames=array();
if(file_exists($plugin_path."/config.php"))
{
include_once($plugin_path."/config.php");
-}
+ if(isset($pluginOptions))
+ foreach( $pluginOptions as $optionKey => $optionValue )
+ {
+ // Set default dependency information if not set in configuration file
+ if(!isset($optionValue['Require']))
+ $optionValue['Require'] = array (
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ )
+ );
+ $options[$optionKey]=$optionValue;
+ }
+}
$sql='SELECT * FROM PluginsConfig WHERE MonitorId=? AND ZoneId=? AND pluginName=?';
foreach( dbFetchAll( $sql, NULL, array( $mid, $zid, $plugin ) ) as $popt )
{
- if(array_key_exists($popt['Name'], $pluginOptions)
- && $popt['Type']==$pluginOptions[$popt['Name']]['Type']
- && $popt['Choices']==$pluginOptions[$popt['Name']]['Choices']
- )
+ if(array_key_exists($popt['Name'], $options)
+ && $popt['Type']==$options[$popt['Name']]['Type'])
{
- $pluginOptions[$popt['Name']]=$popt;
array_push($optionNames, $popt['Name']);
+
+ // Backup dependency information
+ $require = '';
+ if(isset($options[$popt['Name']]['Require']))
+ $require = $options[$popt['Name']]['Require'];
+
+ // Set value from database
+ $options[$popt['Name']]=$popt;
+
+ // Restore dependancy information from backup
+ if(!empty($require))
+ $options[$popt['Name']]['Require'] = $require;
+
+ // Set default dependancy information if not set in configuration
+ else if($popt['Name'] != 'Enabled')
+ $options[$popt['Name']]['Require'] = array (
+ array(
+ 'Name'=>'Enabled',
+ 'Value'=>'Yes'
+ )
+ );
} else {
dbQuery('DELETE FROM PluginsConfig WHERE Id=?', array( $popt['Id'] ) );
}
}
-foreach($pluginOptions as $name => $values)
+
+foreach($options as $name => $values)
{
if(!in_array($name, $optionNames))
{
- $popt=$pluginOptions[$name];
- $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,?,?,?,?)";
- dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Choices'], $mid, $zid, $plugin ) );
+ $popt=$options[$name];
+ switch($popt['Type'])
+ {
+ case "select":
+ $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,?,'','',?,?,?)";
+ dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Choices'], $mid, $zid, $plugin ) );
+ break;
+ case "integer":
+ $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,'',?,?,?,?,?)";
+ dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Min'], $popt['Max'], $mid, $zid, $plugin ) );
+ break;
+ case "checkbox":
+ case "text":
+ default:
+ $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,'','','',?,?,?)";
+ dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $mid, $zid, $plugin ) );
+ }
}
}
$PLANG=array();
-if(file_exists($plugin_path."/lang/".$user['Language'].".php")) {
- include_once($plugin_path."/lang/".$user['Language'].".php");
+$lang_path = $plugin_path."/lang";
+$userLangFile = $lang_path."/".$user['Language'].".php";
+if (isset($user['Language']) && file_exists($userLangFile)) {
+ include_once($userLangFile);
+} else {
+ $systemLangFile = $lang_path."/".ZM_LANG_DEFAULT.".php";
+ if (file_exists($systemLangFile)) {
+ include_once($systemLangFile);
+ } else {
+ $fallbackLangFile = $lang_path."/en_gb.php";
+ if (file_exists($fallbackLangFile)) {
+ include_once($fallbackLangFile);
+ }
+ }
}
function pLang($name)
{
+ global $SLANG;
global $PLANG;
- if(array_key_exists($name, $PLANG))
+ if(array_key_exists($name, $SLANG))
+ return $SLANG[$name];
+ else if(array_key_exists($name, $PLANG))
return $PLANG[$name];
else
return $name;
}
+function isEnabled($param)
+{
+ global $options;
+ $option = $options[$param];
+ if (!isset($option['Require']))
+ return true;
+ foreach($option['Require'] as $req_couple)
+ {
+ $name = $req_couple['Name'];
+ if (!array_key_exists($name, $options))
+ continue;
+ if ($req_couple['Value'] != $options[$name]['Value'])
+ return false;
+ }
+ return true;
+}
+xhtmlHeaders(__FILE__, $SLANG['Plugin'] );
?>
@@ -117,21 +250,23 @@ function pLang($name)
-foreach($pluginOptions as $name => $popt)
+foreach($options as $name => $popt)
{
- ?>
- = pLang($name) ?> |
-
+?>
+
---|
= pLang($name) ?> |
+
switch($popt['Type'])
{
case "checkbox":
- echo "CHECKBOX";
+ ?>
+ > |
+
break;
case "select":
$pchoices=explode(',',$popt['Choices']);
?>
-
+ onchange="applyDependencies()" >
foreach($pchoices as $pchoice)
{
@@ -143,13 +278,22 @@ foreach($pluginOptions as $name => $popt)
}
?>
- |
+
break;
case "text":
+ ?>
+ > |
+
+ break;
+ case "integer":
+ ?>
+ > |
+
+ break;
default:
- echo "DEFAULT";
+ echo "Type '".$popt['Type']."' is not implemented ";
}
?>
diff --git a/web/skins/flat/views/zone.php b/web/skins/flat/views/zone.php
index 980c0e430..2dd7f81a1 100644
--- a/web/skins/flat/views/zone.php
+++ b/web/skins/flat/views/zone.php
@@ -212,6 +212,60 @@ xhtmlHeaders(__FILE__, $SLANG['Zone'] );
= $SLANG['ZoneExtendAlarmFrames'] ?> |
|
+ 0)
+{
+ // Get plugin status from zmu command line
+ exec(escapeshellcmd(getZmuCommand(" -p -m".$mid)), $cmdOutput, $retval);
+ if($retval == 0)
+ {
+ echo "".$SLANG['Plugins']." | \n";
+ $plName = "";
+ $plReg = "0";
+ $plConf = "0";
+ foreach($cmdOutput as $key => $line)
+ {
+ // Skip header lines or "No plugin found"
+ if($key < 2) continue;
+ // Parse line
+ $pl = preg_split ('/[\s]+/ ', trim($line));
+ $offset = 0;
+ if(sizeof($pl) == 9)
+ {
+ $plName = $pl[0];
+ $plReg = $pl[1];
+ $plConf = $pl[2];
+ $offset = 3;
+ }
+ // Skip line if zone mismatch
+ if($pl[$offset] != $zid) continue;
+ // Select class and set display setting
+ $class = '';
+ $dspPlConf = true;
+ if(!ZM_LOAD_PLUGINS) {
+ $class = " class=\"pluginNotEnabled\"";
+ $dspPlConf = false;
+ } else if($plReg == "0" || (($plReg == "1") && ($plConf == "0"))) {
+ $class = " class=\"pluginError\"";
+ $dspPlConf = false;
+ } else if(($pl[1 + $offset] == "1") && ($pl[2 + $offset] == "0")) {
+ $class = " class=\"pluginNotActive\"";
+ } else if($pl[2 + $offset] == "1") {
+ $class = " class=\"pluginActive\"";
+ }
+ // Display plugin name and enable link
+ if($dspPlConf)
+ echo "".$plName." \n";
+ else
+ echo "".$plName." \n";
+ }
+ echo " | \n";
+ }
+}
+?>
|