Skip to content

Commit

Permalink
function Settings::IsInList that tests if an option of a multi-select…
Browse files Browse the repository at this point in the history
… setting is set
  • Loading branch information
micw committed Jul 22, 2016
1 parent a952330 commit 54e2f83
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
17 changes: 17 additions & 0 deletions lib/classes/settings/class.Settings.php
Expand Up @@ -124,6 +124,23 @@ public function pGet($setting = null) {
return $result;
}

/**
* tests if a setting-value that i s a comma separated list contains an entry
*
* @param string $setting a group and a varname separated by a dot (group.varname)
* @param string $entry the entry that is expected to be in the list
*
* @return boolean true, if the list contains $entry
*/
public function pIsInList($setting = null, $entry = null) {
$s=Settings::Get($setting);
if ($s==null) {
return false;
}
$slist = explode(",",$s);
return in_array($entry, $slist);
}

/**
* update a setting / set a new value
*
Expand Down
20 changes: 10 additions & 10 deletions lib/navigation/00.froxlor.main.php
Expand Up @@ -48,7 +48,7 @@
'email' => array (
'url' => 'customer_email.php',
'label' => $lng['menue']['email']['email'],
'show_element' => ( !in_array('email',explode(',',Settings::Get('panel.customer_hide_options'))) ),
'show_element' => ( !Settings::IsInList('panel.customer_hide_options','email') ),
'elements' => array (
array (
'url' => 'customer_email.php?page=emails',
Expand All @@ -72,7 +72,7 @@
'mysql' => array (
'url' => 'customer_mysql.php',
'label' => $lng['menue']['mysql']['mysql'],
'show_element' => ( !in_array('mysql',explode(',',Settings::Get('panel.customer_hide_options'))) ),
'show_element' => ( !Settings::IsInList('panel.customer_hide_options','mysql') ),
'elements' => array (
array (
'url' => 'customer_mysql.php?page=mysqls',
Expand All @@ -91,7 +91,7 @@
'domains' => array (
'url' => 'customer_domains.php',
'label' => $lng['menue']['domains']['domains'],
'show_element' => ( !in_array('domains',explode(',',Settings::Get('panel.customer_hide_options'))) ),
'show_element' => ( !Settings::IsInList('panel.customer_hide_options','domains') ),
'elements' => array (
array (
'url' => 'customer_domains.php?page=domains',
Expand All @@ -102,7 +102,7 @@
'ftp' => array (
'url' => 'customer_ftp.php',
'label' => $lng['menue']['ftp']['ftp'],
'show_element' => ( !in_array('ftp',explode(',',Settings::Get('panel.customer_hide_options'))) ),
'show_element' => ( !Settings::IsInList('panel.customer_hide_options','ftp') ),
'elements' => array (
array (
'url' => 'customer_ftp.php?page=accounts',
Expand All @@ -119,34 +119,34 @@
'extras' => array (
'url' => 'customer_extras.php',
'label' => $lng['menue']['extras']['extras'],
'show_element' => ( !in_array('extras',explode(',',Settings::Get('panel.customer_hide_options'))) ),
'show_element' => ( !Settings::IsInList('panel.customer_hide_options','extras') ),
'elements' => array (
array (
'url' => 'customer_extras.php?page=htpasswds',
'label' => $lng['menue']['extras']['directoryprotection'],
'show_element' => ( !in_array('extras.directoryprotection',explode(',',Settings::Get('panel.customer_hide_options'))) ),
'show_element' => ( !Settings::IsInList('panel.customer_hide_options','extras.directoryprotection') ),
),
array (
'url' => 'customer_extras.php?page=htaccess',
'label' => $lng['menue']['extras']['pathoptions'],
'show_element' => ( !in_array('extras.pathoptions',explode(',',Settings::Get('panel.customer_hide_options'))) ),
'show_element' => ( !Settings::IsInList('panel.customer_hide_options','extras.pathoptions') ),
),
array (
'url' => 'customer_logger.php?page=log',
'label' => $lng['menue']['logger']['logger'],
'show_element' => ( Settings::Get('logger.enabled') == true ) && ( !in_array('extras.logger',explode(',',Settings::Get('panel.customer_hide_options'))) )
'show_element' => ( Settings::Get('logger.enabled') == true ) && ( !Settings::IsInList('panel.customer_hide_options','extras.logger') ),
),
array (
'url' => 'customer_extras.php?page=backup',
'label' => $lng['menue']['extras']['backup'],
'show_element' => ( Settings::Get('system.backupenabled') == true ),
'show_element' => ( Settings::Get('system.backupenabled') == true ) && ( !Settings::IsInList('panel.customer_hide_options','extras.backup') ),
),
),
),
'traffic' => array (
'url' => 'customer_traffic.php',
'label' => $lng['menue']['traffic']['traffic'],
'show_element' => ( !in_array('traffic',explode(',',Settings::Get('panel.customer_hide_options'))) ),
'show_element' => ( !Settings::IsInList('panel.customer_hide_options','traffic') ),
'elements' => array (
array (
'url' => 'customer_traffic.php?page=current',
Expand Down
6 changes: 3 additions & 3 deletions templates/Sparkle/customer/traffic/traffic.tpl
Expand Up @@ -37,15 +37,15 @@ $header
</form>

<div id="charts" class="hidden">
<if !in_array('traffic.http',explode(',',Settings::Get('panel.customer_hide_options')))>
<if !Settings::IsInList('panel.customer_hide_options','traffic.http')>
<h3>HTTP {$lng['admin']['traffic']} ({$lng['traffic']['months']['total']} {$traffic_complete['http']})</h3>
<div id="httpchart" class="trafficchart"></div>
</if>
<if !in_array('traffic.ftp',explode(',',Settings::Get('panel.customer_hide_options')))>
<if !Settings::IsInList('panel.customer_hide_options','traffic.ftp')>
<h3>FTP {$lng['admin']['traffic']} ({$lng['traffic']['months']['total']} {$traffic_complete['ftp']})</h3>
<div id="ftpchart" class="trafficchart"></div>
</if>
<if !in_array('traffic.mail',explode(',',Settings::Get('panel.customer_hide_options')))>
<if !Settings::IsInList('panel.customer_hide_options','traffic.mail')>
<h3>Mail {$lng['admin']['traffic']} ({$lng['traffic']['months']['total']} {$traffic_complete['mail']})</h3>
<div id="mailchart" class="trafficchart"></div>
</if>
Expand Down
6 changes: 3 additions & 3 deletions templates/Sparkle/customer/traffic/traffic_details.tpl
Expand Up @@ -31,15 +31,15 @@ $header
</tbody>
</table>
<div id="charts" class="hidden">
<if !in_array('traffic.http',explode(',',Settings::Get('panel.customer_hide_options')))>
<if !Settings::IsInList('panel.customer_hide_options','traffic.http')>
<h3>HTTP {$lng['admin']['traffic']} ({$lng['traffic']['months']['total']} {$traffic_complete['http']})</h3>
<div id="httpchart" class="trafficchart"></div>
</if>
<if !in_array('traffic.ftp',explode(',',Settings::Get('panel.customer_hide_options')))>
<if !Settings::IsInList('panel.customer_hide_options','traffic.ftp')>
<h3>FTP {$lng['admin']['traffic']} ({$lng['traffic']['months']['total']} {$traffic_complete['ftp']})</h3>
<div id="ftpchart" class="trafficchart"></div>
</if>
<if !in_array('traffic.mail',explode(',',Settings::Get('panel.customer_hide_options')))>
<if !Settings::IsInList('panel.customer_hide_options','traffic.mail')>
<h3>Mail {$lng['admin']['traffic']} ({$lng['traffic']['months']['total']} {$traffic_complete['mail']})</h3>
<div id="mailchart" class="trafficchart"></div>
</if>
Expand Down

0 comments on commit 54e2f83

Please sign in to comment.