Fix a conflict with php variable

This commit is contained in:
Emmanuel Papin 2015-05-06 23:16:09 +02:00
parent 6a8eb03f0a
commit 49116a27d7
2 changed files with 17 additions and 17 deletions

View File

@ -1,6 +1,6 @@
var pluginOptionList = {}; var pluginOptionList = {};
<?php <?php
foreach ( $options as $option ) foreach ( $pOptions as $option )
{ {
?> ?>
pluginOptionList['<?= $option['Name'] ?>'] = {}; pluginOptionList['<?= $option['Name'] ?>'] = {};

View File

@ -108,7 +108,7 @@ $generalOptions=array(
) )
); );
$pluginOptions=$generalOptions; $pOptions=$generalOptions;
$optionNames=array(); $optionNames=array();
if(file_exists($plugin_path."/config.php")) if(file_exists($plugin_path."/config.php"))
{ {
@ -124,33 +124,33 @@ if(file_exists($plugin_path."/config.php"))
'Value'=>'Yes' 'Value'=>'Yes'
) )
); );
$pluginOptions[$optionKey]=$optionValue; $pOptions[$optionKey]=$optionValue;
} }
} }
$sql='SELECT * FROM PluginsConfig WHERE MonitorId=? AND ZoneId=? AND pluginName=?'; $sql='SELECT * FROM PluginsConfig WHERE MonitorId=? AND ZoneId=? AND pluginName=?';
foreach( dbFetchAll( $sql, NULL, array( $mid, $zid, $plugin ) ) as $popt ) foreach( dbFetchAll( $sql, NULL, array( $mid, $zid, $plugin ) ) as $popt )
{ {
if(array_key_exists($popt['Name'], $pluginOptions) if(array_key_exists($popt['Name'], $pOptions)
&& $popt['Type']==$pluginOptions[$popt['Name']]['Type']) && $popt['Type']==$pOptions[$popt['Name']]['Type'])
{ {
array_push($optionNames, $popt['Name']); array_push($optionNames, $popt['Name']);
// Backup dependency information // Backup dependency information
$require = ''; $require = '';
if(isset($pluginOptions[$popt['Name']]['Require'])) if(isset($pOptions[$popt['Name']]['Require']))
$require = $pluginOptions[$popt['Name']]['Require']; $require = $pOptions[$popt['Name']]['Require'];
// Set value from database // Set value from database
$pluginOptions[$popt['Name']]=$popt; $pOptions[$popt['Name']]=$popt;
// Restore dependancy information from backup // Restore dependancy information from backup
if(!empty($require)) if(!empty($require))
$pluginOptions[$popt['Name']]['Require'] = $require; $pOptions[$popt['Name']]['Require'] = $require;
// Set default dependancy information if not set in configuration // Set default dependancy information if not set in configuration
else if($popt['Name'] != 'Enabled') else if($popt['Name'] != 'Enabled')
$pluginOptions[$popt['Name']]['Require'] = array ( $pOptions[$popt['Name']]['Require'] = array (
array( array(
'Name'=>'Enabled', 'Name'=>'Enabled',
'Value'=>'Yes' 'Value'=>'Yes'
@ -161,11 +161,11 @@ foreach( dbFetchAll( $sql, NULL, array( $mid, $zid, $plugin ) ) as $popt )
} }
} }
foreach($pluginOptions as $name => $values) foreach($pOptions as $name => $values)
{ {
if(!in_array($name, $optionNames)) if(!in_array($name, $optionNames))
{ {
$popt=$pluginOptions[$name]; $popt=$pOptions[$name];
switch($popt['Type']) switch($popt['Type'])
{ {
case "select": case "select":
@ -216,16 +216,16 @@ function pLang($name)
function isEnabled($param) function isEnabled($param)
{ {
global $pluginOptions; global $pOptions;
$option = $pluginOptions[$param]; $option = $pOptions[$param];
if (!isset($option['Require'])) if (!isset($option['Require']))
return true; return true;
foreach($option['Require'] as $req_couple) foreach($option['Require'] as $req_couple)
{ {
$name = $req_couple['Name']; $name = $req_couple['Name'];
if (!array_key_exists($name, $pluginOptions)) if (!array_key_exists($name, $pOptions))
continue; continue;
if ($req_couple['Value'] != $pluginOptions[$name]['Value']) if ($req_couple['Value'] != $pOptions[$name]['Value'])
return false; return false;
} }
return true; return true;
@ -250,7 +250,7 @@ xhtmlHeaders(__FILE__, $SLANG['Plugin'] );
<table id="pluginSettings" cellspacing="0"> <table id="pluginSettings" cellspacing="0">
<tbody> <tbody>
<?php <?php
foreach($pluginOptions as $name => $popt) foreach($pOptions as $name => $popt)
{ {
?> ?>
<tr><th scope="row"><?php echo pLang($name) ?></th> <tr><th scope="row"><?php echo pLang($name) ?></th>