Skip to content

Commit

Permalink
Implemented Config::tab_exists, Config::getAllGroups, and Config::get…
Browse files Browse the repository at this point in the history
…AllTabs methods (feature #498)
  • Loading branch information
mystralkk committed Jan 2, 2017
1 parent 825aa5b commit c26c12c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions system/classes/config.class.php
Expand Up @@ -309,6 +309,64 @@ public function group_exists($group)
return array_key_exists($group, $this->config_array);
}

/**
* Check if tab exists or not
*
* @param string $group Group name
* @param string $tab Tab name
* @return bool True if group exists
*/
public function tab_exists($group, $tab)
{
$tab = strtolower($tab);
if (strpos($tab, 'tab_') !== 0) {
$tab = 'tab_' . $tab;
}

if (isset($this->conf_tab_arr[$group])) {
foreach ($this->conf_tab_arr[$group] as $itemGroups) {
foreach ($itemGroups as $tabName => $values) {
if ($tab === $tabName) {
return true;
}
}
}
}

return false;
}

/**
* Return all group names
*
* @return array of group names
*/
public function getAllGroups()
{
return array_keys($this->config_array);
}

/**
* Return all tab names of a given group
*
* @param string $group Group name
* @return array of tab names
*/
public function getAllTabs($group)
{
$retval = array();

if (isset($this->conf_tab_arr[$group])) {
foreach ($this->conf_tab_arr[$group] as $itemGroups) {
foreach ($itemGroups as $tabName => $values) {
$retval[] = str_replace('tab_', '', $tabName);
}
}
}

return $retval;
}

/**
* This method sets a configuration variable to a value in the database
* and in the current array. If the variable does not already exist,
Expand Down

0 comments on commit c26c12c

Please sign in to comment.