diff --git a/system/classes/config.class.php b/system/classes/config.class.php index 90ecab3e7..cedd45ecd 100644 --- a/system/classes/config.class.php +++ b/system/classes/config.class.php @@ -502,7 +502,7 @@ public function add($param_name, $default_value, $type, $subgroup, $fieldset = n $Qargs[9] = $tab; } $Qargs = array_map('DB_escapeString', $Qargs); - + // Delete old config value if exists (incase re-adding it for developer db update script) $sql = "DELETE FROM {$_TABLES['conf_values']} WHERE name = '{$Qargs[0]}' AND group_name = '{$Qargs[4]}' AND subgroup={$Qargs[3]}"; $this->_DB_escapedQuery($sql); @@ -559,35 +559,37 @@ public function add($param_name, $default_value, $type, $subgroup, $fieldset = n * @param string $tab the tab to display the variable under */ function update($param_name, $default_value, $type, $subgroup, $fieldset, - $selection_array=null, $sort=0, $set=true, $group='Core', $tab = null) + $selection_array = null, $sort = 0, $set = true, $group = 'Core', $tab = null) { global $_TABLES; - $Qargs = array($param_name, - $set ? serialize($default_value) : 'unset', - $type, - $subgroup, - $group, - ($selection_array === null ? - -1 : $selection_array), - $sort, - $fieldset, - serialize($default_value)); - + $columns = ''; + $Qargs = array( + $param_name, + ($set ? serialize($default_value) : 'unset'), + $type, + $subgroup, + $group, + ($selection_array === null ? -1 : $selection_array), + $sort, + $fieldset, + serialize($default_value), + ); + // special handling of $tab for backward compatibility if ($tab !== null) { $columns .= ', tab'; $Qargs[9] = $tab; - } - + } + $Qargs = array_map('DB_escapeString', $Qargs); - $sql = "UPDATE {$_TABLES['conf_values']} SET sort_order={$Qargs[6]},fieldset={$Qargs[7]}". - " WHERE group_name='{$Qargs[4]}' AND name='{$Qargs[0]}'"; + $sql = "UPDATE {$_TABLES['conf_values']} SET sort_order={$Qargs[6]},fieldset={$Qargs[7]}" . + " WHERE group_name='{$Qargs[4]}' AND name='{$Qargs[0]}'"; - $this->_DB_escapedQuery($sql,1); + $this->_DB_escapedQuery($sql, 1); } - + /** * Permanently deletes a parameter * @@ -615,12 +617,10 @@ function _get_extended($subgroup, $group) { global $_TABLES, $LANG_confignames, $LANG_configselects; - $q_string = "SELECT name, type, selectionArray, " - . "tab, value, default_value, fieldset FROM {$_TABLES['conf_values']}" . - " WHERE group_name='{$group}' AND subgroup='{$subgroup}' " . - " AND (type <> 'tab' AND type <> 'subgroup') " . - " ORDER BY tab,fieldset,sort_order ASC"; - + $q_string = "SELECT name, type, selectionArray, tab, value, default_value, fieldset FROM {$_TABLES['conf_values']}" + . " WHERE group_name='" . DB_escapeString($group) . "' AND subgroup='" . DB_escapeString($subgroup) . "' " + . " AND (type <> 'tab' AND type <> 'subgroup') " + . " ORDER BY tab, fieldset, sort_order ASC"; $Qresult = DB_query($q_string); $res = array(); if (!array_key_exists($group, $LANG_configselects)) { @@ -637,28 +637,15 @@ function _get_extended($subgroup, $group) $cur[3] = 0; } // If tab is null then old plugin so set default tab - if (substr($cur[5], 0, 6) === 'unset:') { - $cur[5] = true; - } else { - $cur[5] = false; - } - $res[$cur[3]][$cur[0]] = - array('display_name' => - (array_key_exists($cur[0], $LANG_confignames[$group]) ? - $LANG_confignames[$group][$cur[0]] - : $cur[0]), - 'type' => - (($cur[4] == 'unset') ? - 'unset' : $cur[1]), - 'selectionArray' => - (($cur[2] != -1) ? - //isset($LANG_configselects[$group][$cur[2]]) : null), - $LANG_configselects[$group][$cur[2]] : null), - 'value' => - (($cur[4] == 'unset') ? - 'unset' : unserialize($cur[4])), - 'fieldset' => $cur[6], - 'reset' => $cur[5]); + $cur[5] = (substr($cur[5], 0, 6) === 'unset:'); + $res[$cur[3]][$cur[0]] = array( + 'display_name' => (array_key_exists($cur[0], $LANG_confignames[$group]) ? $LANG_confignames[$group][$cur[0]] : $cur[0]), + 'type' => (($cur[4] === 'unset') ? 'unset' : $cur[1]), + 'selectionArray' => (($cur[2] != -1) ? $LANG_configselects[$group][$cur[2]] : null), + 'value' => (($cur[4] === 'unset') ? 'unset' : unserialize($cur[4])), + 'fieldset' => $cur[6], + 'reset' => $cur[5], + ); } return $res; @@ -819,7 +806,7 @@ function _get_fs_name($tab_id, $fs_id) */ public function get_ui($grp, $sg = '0', $change_result = null) { - global $_CONF, $LANG_CONFIG, $LANG_configsubgroups, $LANG_fs, $_SCRIPTS, $LANG01; + global $_CONF, $LANG_CONFIG, $LANG_configsubgroups, $LANG_fs, $_SCRIPTS, $_USER, $LANG01; if (!array_key_exists($grp, $LANG_configsubgroups)) { $LANG_configsubgroups[$grp] = array(); @@ -847,8 +834,10 @@ public function get_ui($grp, $sg = '0', $change_result = null) } $t = COM_newTemplate($_CONF['path_layout'] . 'admin/config'); - $t->set_file(array('main' => 'configuration.thtml', - 'menugroup' => 'menu_element.thtml')); + $t->set_file(array( + 'main' => 'configuration.thtml', + 'menugroup' => 'menu_element.thtml', + )); $link_message = $LANG01[139]; $t->set_var('noscript', COM_getNoScript(false, '', $link_message)); @@ -892,7 +881,7 @@ public function get_ui($grp, $sg = '0', $change_result = null) $t->set_var('open_group', $grp); - $outerloopcntr = 1; + $outerLoopCounter = 1; if (count($groups) > 0) { $t->set_block('menugroup', 'subgroup-selector', 'subgroups'); foreach ($groups as $group) { @@ -900,16 +889,15 @@ public function get_ui($grp, $sg = '0', $change_result = null) $t->set_var("group_select_value", $group); $t->set_var("group_display", ucwords($group)); $subgroups = $this->_get_sgroups($group); - $innerloopcntr = 1; + + $innerLoopCounter = 1; foreach ($subgroups as $sgname => $sgroup) { - if ($grp == $group AND $sg == $sgroup) { + if ($grp == $group && $sg == $sgroup) { $t->set_var('group_active_name', ucwords($group)); if (isset($LANG_configsubgroups[$group][$sgname])) { - $t->set_var('subgroup_active_name', - $LANG_configsubgroups[$group][$sgname]); + $t->set_var('subgroup_active_name', $LANG_configsubgroups[$group][$sgname]); } elseif (isset($LANG_configsubgroups[$group][$sgroup])) { - $t->set_var('subgroup_active_name', - $LANG_configsubgroups[$group][$sgroup]); + $t->set_var('subgroup_active_name', $LANG_configsubgroups[$group][$sgroup]); } else { $t->set_var('subgroup_active_name', $sgname); } @@ -924,16 +912,16 @@ public function get_ui($grp, $sg = '0', $change_result = null) } else { $t->set_var('subgroup_display_name', $sgname); } - if ($innerloopcntr == 1) { + if ($innerLoopCounter == 1) { $t->parse('subgroups', "subgroup-selector"); } else { $t->parse('subgroups', "subgroup-selector", true); } - $innerloopcntr++; + $innerLoopCounter++; } - $t->set_var('cntr', $outerloopcntr); + $t->set_var('cntr', $outerLoopCounter); $t->parse("menu_elements", "menugroup", true); - $outerloopcntr++; + $outerLoopCounter++; } } else { $t->set_var('hide_groupselection', 'none'); @@ -951,7 +939,7 @@ public function get_ui($grp, $sg = '0', $change_result = null) $fs_flag = false; $table_flag = false; foreach ($params as $name => $e) { - if ($e['type'] == 'fieldset' AND $e['fieldset'] != $current_fs) { + if ($e['type'] === 'fieldset' && $e['fieldset'] != $current_fs) { $fs_flag = true; if ($current_fs != '') { @@ -967,7 +955,6 @@ public function get_ui($grp, $sg = '0', $change_result = null) $current_fs = $e['fieldset']; } if (!$table_flag) { - if ($this->flag_version_2 == true) { $tab_contents .= '